-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathprogramming.html
976 lines (860 loc) · 46.9 KB
/
programming.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Programming with Radiant</title>
<script src="libs/header-attrs-2.28/header-attrs.js"></script>
<script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="libs/bootstrap-3.3.5/css/cosmo.min.css" rel="stylesheet" />
<script src="libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="libs/navigation-1.1/tabsets.js"></script>
<style type="text/css">
/* padding for bootstrap navbar */
body {
padding-top: 50px;
padding-bottom: 40px;
}
/* offset scroll position for anchor links (for fixed navbar) */
.section h2 {
padding-top: 55px;
margin-top: -55px;
}
.section h3 {
padding-top: 55px;
margin-top: -55px;
}
/* don't use link color in navbar */
.dropdown-menu>li>a {
display: inline;
color: black;
padding-top: 0;
padding-bottom: 0;
}
.dropdown-menu .divider {
margin-top: 2px;
margin-bottom: 2px;
}
img {
max-width: 85% !important;
}
/*
img.center {
display: block;
margin: 0 auto;
}
*/
</style>
<link rel="stylesheet" href="libs/font-awesome-4.1.0/css/font-awesome.min.css"/>
<link rel="shortcut icon" type="image/png" href="/docs/images/icon.png"/>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">
code {
white-space: pre;
}
.sourceCode {
overflow: visible;
}
</style>
<style type="text/css" data-origin="pandoc">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ color: #cccccc; background-color: #303030; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ffcfaf; } /* Alert */
code span.an { color: #7f9f7f; font-weight: bold; } /* Annotation */
code span.at { } /* Attribute */
code span.bn { color: #dca3a3; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #f0dfaf; } /* ControlFlow */
code span.ch { color: #dca3a3; } /* Char */
code span.cn { color: #dca3a3; font-weight: bold; } /* Constant */
code span.co { color: #7f9f7f; } /* Comment */
code span.cv { color: #7f9f7f; font-weight: bold; } /* CommentVar */
code span.do { color: #7f9f7f; } /* Documentation */
code span.dt { color: #dfdfbf; } /* DataType */
code span.dv { color: #dcdccc; } /* DecVal */
code span.er { color: #c3bf9f; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #c0bed1; } /* Float */
code span.fu { color: #efef8f; } /* Function */
code span.im { } /* Import */
code span.in { color: #7f9f7f; font-weight: bold; } /* Information */
code span.kw { color: #f0dfaf; } /* Keyword */
code span.op { color: #f0efd0; } /* Operator */
code span.ot { color: #efef8f; } /* Other */
code span.pp { color: #ffcfaf; font-weight: bold; } /* Preprocessor */
code span.sc { color: #dca3a3; } /* SpecialChar */
code span.ss { color: #cc9393; } /* SpecialString */
code span.st { color: #cc9393; } /* String */
code span.va { } /* Variable */
code span.vs { color: #cc9393; } /* VerbatimString */
code span.wa { color: #7f9f7f; font-weight: bold; } /* Warning */
</style>
<script>
// apply pandoc div.sourceCode style to pre.sourceCode instead
(function() {
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
var j = 0;
while (j < rules.length) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") {
j++;
continue;
}
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' && rule.style.backgroundColor === '') {
j++;
continue;
}
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
details > summary > p:only-child {
display: inline;
}
pre code {
padding: 0;
}
</style>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "\e259";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "\e258";
font-family: 'Glyphicons Halflings';
border: none;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
</head>
<body>
<div class="container-fluid main-container">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://github.com/radiant-rstats/docs">Radiant</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/docs/index.html">Home</a></li>
<li><a href="/docs/news.html">News</a></li>
<li><a href="/docs/install.html">Install</a></li>
<li class="dropdown">
<a href="/docs/data/" class="dropdown-toggle" data-toggle="dropdown" role="button"
aria-expanded="false">Data<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="/docs/data/manage.html">Manage</a></li>
<li><a href="/docs/data/view.html">View</a></li>
<li><a href="/docs/data/visualize.html">Visualize</a></li>
<li><a href="/docs/data/pivotr.html">Pivot</a></li>
<li><a href="/docs/data/explore.html">Explore</a></li>
<li><a href="/docs/data/transform.html">Transform</a></li>
<li><a href="/docs/data/combine.html">Combine</a></li>
</ul>
</li>
<li class="dropdown">
<a href="/docs/design/" class="dropdown-toggle" data-toggle="dropdown" role="button"
aria-expanded="false">Design<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class="dropdown-header">DOE</li>
<li><a href="/docs/design/doe.html">Design of Experiments (DOE)</a></li>
<li class="divider"></li>
<li class="dropdown-header">Sample</li>
<li><a href="/docs/design/sampling.html">Random sampling</a></li>
<li><a href="/docs/design/randomizer.html">Random assignment</a></li>
<li><a href="/docs/design/sample_size.html">Sample size (single)</a></li>
<li><a href="/docs/design/sample_size_comp.html">Sample size (compare)</a></li>
</ul>
</li>
<li class="dropdown">
<a href="/docs/basics/" class="dropdown-toggle" data-toggle="dropdown" role="button"
aria-expanded="false">Basics<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class="dropdown-header">Probability</li>
<li><a href="/docs/basics/prob_calc.html">Probability calculator</a></li>
<li><a href="/docs/basics/clt.html">Central Limit Theorem</a></li>
<li class="divider"></li>
<li class="dropdown-header">Means</li>
<li><a href="/docs/basics/single_mean.html">Single mean</a></li>
<li><a href="/docs/basics/compare_means.html">Compare means</a></li>
<li class="divider"></li>
<li class="dropdown-header">Proportions</li>
<li><a href="/docs/basics/single_prop.html">Single proportion</a></li>
<li><a href="/docs/basics/compare_props.html">Compare proportions</a></li>
<li class="divider"></li>
<li class="dropdown-header">Tables</li>
<li><a href="/docs/basics/goodness.html">Goodness of fit</a></li>
<li><a href="/docs/basics/cross_tabs.html">Cross-tabs</a></li>
<li><a href="/docs/basics/correlation.html">Correlation</a></li>
</ul>
</li>
<li class="dropdown">
<a href="/docs/model/" class="dropdown-toggle" data-toggle="dropdown" role="button"
aria-expanded="false">Model<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class="dropdown-header">Estimate</li>
<li><a href="/docs/model/regress.html">Linear regression (OLS)</a></li>
<li><a href="/docs/model/logistic.html">Logistic regression (GLM)</a></li>
<li><a href="/docs/model/mnl.html">Multinomial logistic regression (MNL)</a></li>
<li><a href="/docs/model/nn.html">Neural Network</a></li>
<li><a href="/docs/model/nb.html">Naive Bayes</a></li>
<li class="divider"></li>
<li class="dropdown-header">Trees</li>
<li><a href="/docs/model/crtree.html">Classification and regression trees</a></li>
<li><a href="/docs/model/rforest.html">Random Forest</a></li>
<li><a href="/docs/model/gbt.html">Gradient Boosted Trees</a></li>
<li class="divider"></li>
<li class="dropdown-header">Evaluate</li>
<li><a href="/docs/model/evalreg.html">Evaluate regression</a></li>
<li><a href="/docs/model/evalbin.html">Evaluate classification</a></li>
<li class="divider"></li>
<li class="dropdown-header">Recommend</li>
<li><a href="/docs/model/crs.html">Collaborative Filtering</a></li>
<li class="divider"></li>
<li class="dropdown-header">Decide</li>
<li><a href="/docs/model/dtree.html">Decision analysis</a></li>
<li><a href="/docs/model/simulater.html">Simulate</a></li>
</ul>
</li>
<li class="dropdown">
<a href="/docs/multivariate/" class="dropdown-toggle" data-toggle="dropdown" role="button"
aria-expanded="false">Multivariate<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class="dropdown-header">Maps</li>
<li><a href="/docs/multivariate/mds.html">(Dis)similarity</a></li>
<li><a href="/docs/multivariate/prmap.html">Attributes</a></li>
<li class="divider"></li>
<li class="dropdown-header">Factor</li>
<li><a href="/docs/multivariate/pre_factor.html">Pre-factor</a></li>
<li><a href="/docs/multivariate/full_factor.html">Factor</a></li>
<li class="divider"></li>
<li class="dropdown-header">Cluster</li>
<li><a href="/docs/multivariate/hclus.html">Hierarchical</a></li>
<li><a href="/docs/multivariate/kclus.html">K-clustering</a></li>
<li class="divider"></li>
<li class="dropdown-header">Conjoint</li>
<li><a href="/docs/multivariate/conjoint.html">Conjoint</a></li>
</ul>
</li>
<li class="dropdown">
<a href="/docs/R/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">R<span
class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="/docs/data/report_rmd.html">Report > Rmd</a></li>
<li><a href="/docs/data/report_r.html">Report > R</a></li>
<li><a href="/docs/programming.html">Programming</a></li>
<li><a href="/docs/resources.html">Resources</a></li>
</ul>
</li>
<li class="dropdown">
<a href="/docs/tutorials/" class="dropdown-toggle" data-toggle="dropdown" role="button"
aria-expanded="false">Tutorials<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="/docs/tutorials.html">Introduction to Radiant</a></li>
<li><a href="/docs/radiant-tutorial-series.html">Radiant Tutorial Series</a></li>
</ul>
</li>
<li><a href="/docs/about.html">About</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
<style>
.btn,
.form-control,
pre,
code,
pre code {
border-radius: 4px;
}
.table {
width: auto;
}
ul,
ol {
padding-left: 18px;
}
code,
pre,
pre code {
overflow: auto;
white-space: pre;
word-wrap: normal;
}
code {
color: #c7254e;
background-color: #f9f2f4;
}
pre {
background-color: #ffffff;
}
</style>
<div id="header">
<h1 class="title toc-ignore">Programming with Radiant</h1>
</div>
<p>Radiant’s goal is to provide access to the power of R for business
analytics and data science. Although Radiant’s web-interface can handle
many data and analysis tasks, you may prefer to write your own code.
Radiant provides a bridge to programming in R(studio) by exporting the
functions used for analysis. For example, you can run your analyses in
Radiant and output the relevant function calls to an R or <a
href="https://rmarkdown.rstudio.com/">Rmarkdown</a> document. Most pages
in the app have an <i title='Report results' class='fa fa-edit'></i>
icon on the bottom left of your screen that you can click to generate a
(reproducible) report with your analysis in the <em>Report > Rmd</em>
(or <em>Report > R</em>) tab. As an alternative to clicking the
<i title='Report results' class='fa fa-edit'></i> icon you can also
press <code>ALT-enter</code> on your keyboard. Click the
<code>Knit report</code> button on the <em>Report > Rmd</em> page to
render the report to HTML or press the <code>Save report</code> button
to produce a Notebook, HTML, PDF, Word, or Rmarkdown file.</p>
<p>To review the functions used in radiant see the <a
href="https://github.com/r-lib/pkgdown">pkgdown</a> documentation
sites:</p>
<ul>
<li><a href="http://radiant-rstats.github.io/radiant"
class="uri">http://radiant-rstats.github.io/radiant</a></li>
<li><a href="http://radiant-rstats.github.io/radiant.data"
class="uri">http://radiant-rstats.github.io/radiant.data</a></li>
<li><a href="http://radiant-rstats.github.io/radiant.design"
class="uri">http://radiant-rstats.github.io/radiant.design</a></li>
<li><a href="http://radiant-rstats.github.io/radiant.basics"
class="uri">http://radiant-rstats.github.io/radiant.basics</a></li>
<li><a href="http://radiant-rstats.github.io/radiant.model"
class="uri">http://radiant-rstats.github.io/radiant.model</a></li>
<li><a href="http://radiant-rstats.github.io/radiant.multivariate"
class="uri">http://radiant-rstats.github.io/radiant.multivariate</a></li>
</ul>
<p>You can also use Rstudio to render and edit Rmarkdown documents
generated in Radiant. When you install and load Radiant it exports
functions that can be called from R-code and/or an Rmarkdown document.
For example, you can paste the commands below into the command console
to get the same output as in the browser interface.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="fu">library</span>(radiant)</span>
<span id="cb1-2"><a href="#cb1-2" tabindex="-1"></a><span class="fu">data</span>(diamonds, <span class="at">package =</span> <span class="st">"radiant.data"</span>, <span class="at">envir =</span> <span class="fu">environment</span>())</span>
<span id="cb1-3"><a href="#cb1-3" tabindex="-1"></a>result <span class="ot"><-</span> <span class="fu">single_mean</span>(diamonds, <span class="st">"price"</span>)</span>
<span id="cb1-4"><a href="#cb1-4" tabindex="-1"></a><span class="fu">summary</span>(result)</span></code></pre></div>
<pre><code>Single mean test
Data : diamonds
Variable : price
Confidence: 0.95
Null hyp. : the mean of price = 0
Alt. hyp. : the mean of price is not equal to 0
mean n n_missing sd se me
3,907.186 3,000 0 3,956.915 72.243 141.651
diff se t.value p.value df 2.5% 97.5%
3907.186 72.243 54.084 < .001 2999 3765.535 4048.837 ***
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a><span class="fu">plot</span>(result)</span></code></pre></div>
<p><img src="programming_files/figure-html/unnamed-chunk-1-1.png" width="672" /></p>
<p>You can also call functions for visualization (see below) and access
help from the console using <code>?visualize</code></p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a><span class="fu">visualize</span>(</span>
<span id="cb4-2"><a href="#cb4-2" tabindex="-1"></a> diamonds,</span>
<span id="cb4-3"><a href="#cb4-3" tabindex="-1"></a> <span class="at">xvar =</span> <span class="st">"carat"</span>,</span>
<span id="cb4-4"><a href="#cb4-4" tabindex="-1"></a> <span class="at">yvar =</span> <span class="st">"price"</span>,</span>
<span id="cb4-5"><a href="#cb4-5" tabindex="-1"></a> <span class="at">type =</span> <span class="st">"scatter"</span>,</span>
<span id="cb4-6"><a href="#cb4-6" tabindex="-1"></a> <span class="at">facet_row =</span> <span class="st">"clarity"</span>,</span>
<span id="cb4-7"><a href="#cb4-7" tabindex="-1"></a> <span class="at">color =</span> <span class="st">"clarity"</span>,</span>
<span id="cb4-8"><a href="#cb4-8" tabindex="-1"></a> <span class="at">labs =</span> <span class="fu">list</span>(<span class="at">title =</span> <span class="st">"Diamond Prices ($)"</span>),</span>
<span id="cb4-9"><a href="#cb4-9" tabindex="-1"></a> <span class="at">custom =</span> <span class="cn">FALSE</span></span>
<span id="cb4-10"><a href="#cb4-10" tabindex="-1"></a>)</span></code></pre></div>
<p><img src="programming_files/figure-html/scatter-1.png" width="480" /></p>
<p>As an example, you can render the <a
href="https://radiant-rstats.github.io/docs/examples/single_mean.Rmd"><code>single_mean.Rmd</code></a>
file into html (or PDF or Word if you prefer) in Rstudio. Try the code
in <a
href="https://radiant-rstats.github.io/docs/examples/radiant_rcode.R"><code>radiant_rcode.R</code></a>
for a more extensive example.</p>
<p>To install Radiant with complete documentation for offline access,
open R(studio) and copy-and-paste the commands below:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a><span class="fu">options</span>(<span class="at">repos =</span> <span class="fu">c</span>(<span class="at">RSM =</span> <span class="st">"https://radiant-rstats.github.io/minicran"</span>, <span class="at">CRAN =</span> <span class="st">"https://cloud.r-project.org"</span>))</span>
<span id="cb5-2"><a href="#cb5-2" tabindex="-1"></a><span class="fu">install.packages</span>(<span class="st">"radiant"</span>)</span>
<span id="cb5-3"><a href="#cb5-3" tabindex="-1"></a><span class="fu">library</span>(radiant)</span></code></pre></div>
<p>This will install and load the library and the required packages. To
see the index of functions currently available in, for example,
Radiant’s Model menu use the
<code>help(package = "radiant.model")</code> command</p>
<p>Lets start by comparing the mean of a variable to a (population)
value using R’s built-in <code>mtcars</code> dataset. This functionality
is in the Radiant menu <em>Basics > Means > Single mean</em>. The
analysis is conducted in function <code>single_mean</code>. Calling the
<code>summary</code> method on the result object will show tabular
output. Calling <code>plot</code> on the same result object will produce
relevant plots.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" tabindex="-1"></a>result <span class="ot"><-</span> <span class="fu">single_mean</span>(</span>
<span id="cb6-2"><a href="#cb6-2" tabindex="-1"></a> mtcars,</span>
<span id="cb6-3"><a href="#cb6-3" tabindex="-1"></a> <span class="at">var =</span> <span class="st">"mpg"</span>,</span>
<span id="cb6-4"><a href="#cb6-4" tabindex="-1"></a> <span class="at">comp_value =</span> <span class="dv">20</span>,</span>
<span id="cb6-5"><a href="#cb6-5" tabindex="-1"></a> <span class="at">alternative =</span> <span class="st">"greater"</span></span>
<span id="cb6-6"><a href="#cb6-6" tabindex="-1"></a>)</span>
<span id="cb6-7"><a href="#cb6-7" tabindex="-1"></a><span class="fu">summary</span>(result)</span></code></pre></div>
<pre><code>Single mean test
Data : mtcars
Variable : mpg
Confidence: 0.95
Null hyp. : the mean of mpg = 20
Alt. hyp. : the mean of mpg is > 20
mean n n_missing sd se me
20.091 32 0 6.027 1.065 2.173
diff se t.value p.value df 5% 100%
0.091 1.065 0.085 0.466 31 18.284 Inf
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" tabindex="-1"></a><span class="fu">plot</span>(result, <span class="at">plots =</span> <span class="fu">c</span>(<span class="st">"hist"</span>, <span class="st">"simulate"</span>))</span></code></pre></div>
<p><img src="programming_files/figure-html/single_mean_mpg-1.png" width="480" /></p>
<p>To compare the mean price of diamonds across different levels of
clarity we can call the <code>compare_means</code> function:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" tabindex="-1"></a>result <span class="ot"><-</span> <span class="fu">compare_means</span>(</span>
<span id="cb9-2"><a href="#cb9-2" tabindex="-1"></a> diamonds,</span>
<span id="cb9-3"><a href="#cb9-3" tabindex="-1"></a> <span class="at">var1 =</span> <span class="st">"clarity"</span>,</span>
<span id="cb9-4"><a href="#cb9-4" tabindex="-1"></a> <span class="at">var2 =</span> <span class="st">"price"</span>,</span>
<span id="cb9-5"><a href="#cb9-5" tabindex="-1"></a> <span class="at">adjust =</span> <span class="st">"bonf"</span></span>
<span id="cb9-6"><a href="#cb9-6" tabindex="-1"></a>)</span>
<span id="cb9-7"><a href="#cb9-7" tabindex="-1"></a><span class="fu">summary</span>(result)</span></code></pre></div>
<pre><code>Pairwise mean comparisons (t-test)
Data : diamonds
Variables : clarity, price
Samples : independent
Confidence: 0.95
Adjustment: Bonferroni
clarity mean n n_missing sd se me
I1 4,194.775 40 0 2,519.678 398.396 805.832
SI2 5,100.189 529 0 4,406.982 191.608 376.407
SI1 3,998.577 721 0 3,813.190 142.011 278.804
VS2 3,822.967 661 0 3,917.484 152.372 299.193
VS1 3,789.181 442 0 3,880.907 184.596 362.797
VVS2 3,337.820 284 0 3,932.706 233.363 459.348
VVS1 2,608.460 224 0 3,201.282 213.895 421.513
IF 2,411.697 99 0 3,330.560 334.734 664.268
Null hyp. Alt. hyp. diff p.value
I1 = SI2 I1 not equal to SI2 -905.414 1
I1 = SI1 I1 not equal to SI1 196.198 1
I1 = VS2 I1 not equal to VS2 371.808 1
I1 = VS1 I1 not equal to VS1 405.594 1
I1 = VVS2 I1 not equal to VVS2 856.955 1
I1 = VVS1 I1 not equal to VVS1 1586.315 0.023 *
I1 = IF I1 not equal to IF 1783.078 0.025 *
SI2 = SI1 SI2 not equal to SI1 1101.612 < .001 ***
SI2 = VS2 SI2 not equal to VS2 1277.222 < .001 ***
SI2 = VS1 SI2 not equal to VS1 1311.008 < .001 ***
SI2 = VVS2 SI2 not equal to VVS2 1762.369 < .001 ***
SI2 = VVS1 SI2 not equal to VVS1 2491.729 < .001 ***
SI2 = IF SI2 not equal to IF 2688.492 < .001 ***
SI1 = VS2 SI1 not equal to VS2 175.610 1
SI1 = VS1 SI1 not equal to VS1 209.396 1
SI1 = VVS2 SI1 not equal to VVS2 660.757 0.446
SI1 = VVS1 SI1 not equal to VVS1 1390.117 < .001 ***
SI1 = IF SI1 not equal to IF 1586.880 0.001 ***
VS2 = VS1 VS2 not equal to VS1 33.786 1
VS2 = VVS2 VS2 not equal to VVS2 485.146 1
VS2 = VVS1 VS2 not equal to VVS1 1214.507 < .001 ***
VS2 = IF VS2 not equal to IF 1411.270 0.005 **
VS1 = VVS2 VS1 not equal to VVS2 451.361 1
VS1 = VVS1 VS1 not equal to VVS1 1180.721 0.001 ***
VS1 = IF VS1 not equal to IF 1377.484 0.012 *
VVS2 = VVS1 VVS2 not equal to VVS1 729.361 0.606
VVS2 = IF VVS2 not equal to IF 926.123 0.68
VVS1 = IF VVS1 not equal to IF 196.763 1
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" tabindex="-1"></a><span class="fu">plot</span>(result, <span class="at">plots =</span> <span class="fu">c</span>(<span class="st">"bar"</span>, <span class="st">"density"</span>))</span></code></pre></div>
<p><img src="programming_files/figure-html/compare_means_diamonds-1.png" width="384" /></p>
<p>To get help for the <code>single_mean</code> and
<code>compare_means</code> functions use <code>?single_mean</code> and
<code>?compare_means</code>. These help files also have links to
information about the <code>summary</code> and <code>plot</code> methods
for each class. See also <code>?summary.single_mean</code> and
<code>?plot.compare_means</code></p>
<p>These datasets are available after loading the radiant library by
using the <code>data</code> function. We can also load data through
Radiant’s browser interface and then access the data from the console
after closing the app. Start radiant using the command below and then
click select <code>Examples</code> from the
<code>Load data of type</code> dropdown in the <em>Data > Manage</em>
tab. Then close the app by clicking the
<i title='Power off' class='fa fa-power-off'></i> icon in the navbar and
then clicking <code>Stop</code>. The datasets loaded through the
web-interface are now available in the <code>r_data</code> environment
as well. To use them directly in your code use
<code>attach(r_data)</code>.</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" tabindex="-1"></a><span class="do">## start radiant in Rstudio, load the example data, then click the power icon and Stop</span></span>
<span id="cb12-2"><a href="#cb12-2" tabindex="-1"></a>radiant<span class="sc">::</span><span class="fu">radiant</span>()</span></code></pre></div>
<p>Because we already loaded the radiant library we already have access
to all the data we need here. Lets use the <code>compare_means</code>
function to evaluate salary data for professors of different ranks
using:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" tabindex="-1"></a>result <span class="ot"><-</span> <span class="fu">compare_means</span>(salary, <span class="at">var1 =</span> <span class="st">"rank"</span>, <span class="at">var2 =</span> <span class="st">"salary"</span>)</span>
<span id="cb13-2"><a href="#cb13-2" tabindex="-1"></a><span class="fu">summary</span>(result)</span></code></pre></div>
<pre><code>Pairwise mean comparisons (t-test)
Data : salary
Variables : rank, salary
Samples : independent
Confidence: 0.95
Adjustment: None
rank mean n n_missing sd se me
AsstProf 80,775.985 67 0 8,174.113 998.627 1,993.823
AssocProf 93,876.438 64 0 13,831.700 1,728.962 3,455.056
Prof 126,772.109 266 0 27,718.675 1,699.541 3,346.322
Null hyp. Alt. hyp. diff p.value
AsstProf = AssocProf AsstProf not equal to AssocProf -13100.45 < .001 ***
AsstProf = Prof AsstProf not equal to Prof -45996.12 < .001 ***
AssocProf = Prof AssocProf not equal to Prof -32895.67 < .001 ***
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" tabindex="-1"></a><span class="fu">plot</span>(result)</span></code></pre></div>
<p><img src="programming_files/figure-html/compare_means_salary-1.png" width="384" /></p>
<p>An alternative way to write this code is to use <code>piping</code>
(see <a
href="https://cran.r-project.org/web/packages/dplyr/vignettes/introduction.html">dplyr</a>
and <a
href="https://cran.r-project.org/web/packages/magrittr/vignettes/magrittr.html">magrittr</a>
vignettes):</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" tabindex="-1"></a>salary <span class="sc">%>%</span></span>
<span id="cb16-2"><a href="#cb16-2" tabindex="-1"></a> <span class="fu">compare_means</span>(<span class="st">"rank"</span>, <span class="st">"salary"</span>) <span class="sc">%>%</span></span>
<span id="cb16-3"><a href="#cb16-3" tabindex="-1"></a> {</span>
<span id="cb16-4"><a href="#cb16-4" tabindex="-1"></a> <span class="fu">summary</span>(.)</span>
<span id="cb16-5"><a href="#cb16-5" tabindex="-1"></a> <span class="fu">plot</span>(.)</span>
<span id="cb16-6"><a href="#cb16-6" tabindex="-1"></a> }</span></code></pre></div>
<pre><code>Pairwise mean comparisons (t-test)
Data : .
Variables : rank, salary
Samples : independent
Confidence: 0.95
Adjustment: None
rank mean n n_missing sd se me
AsstProf 80,775.985 67 0 8,174.113 998.627 1,993.823
AssocProf 93,876.438 64 0 13,831.700 1,728.962 3,455.056
Prof 126,772.109 266 0 27,718.675 1,699.541 3,346.322
Null hyp. Alt. hyp. diff p.value
AsstProf = AssocProf AsstProf not equal to AssocProf -13100.45 < .001 ***
AsstProf = Prof AsstProf not equal to Prof -45996.12 < .001 ***
AssocProf = Prof AssocProf not equal to Prof -32895.67 < .001 ***
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<p><img src="programming_files/figure-html/compare_means_salary_piped-1.png" width="384" /></p>
<p>We can also run regressions and get output in a format that would
require many lines of code to produce from scratch:</p>
<div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" tabindex="-1"></a>result <span class="ot"><-</span> <span class="fu">regress</span>(diamonds, <span class="at">rvar =</span> <span class="st">"price"</span>, <span class="at">evar =</span> <span class="fu">c</span>(<span class="st">"carat"</span>, <span class="st">"clarity"</span>))</span>
<span id="cb18-2"><a href="#cb18-2" tabindex="-1"></a><span class="fu">summary</span>(result, <span class="at">sum_check =</span> <span class="st">"confint"</span>)</span></code></pre></div>
<pre><code>Linear regression (OLS)
Data : diamonds
Response variable : price
Explanatory variables: carat, clarity
Null hyp.: the effect of x on price is zero
Alt. hyp.: the effect of x on price is not zero
coefficient std.error t.value p.value
(Intercept) -6780.993 204.952 -33.086 < .001 ***
carat 8438.030 51.101 165.125 < .001 ***
clarity|SI2 2790.760 201.395 13.857 < .001 ***
clarity|SI1 3608.531 200.508 17.997 < .001 ***
clarity|VS2 4249.906 201.607 21.080 < .001 ***
clarity|VS1 4461.956 204.592 21.809 < .001 ***
clarity|VVS2 5109.476 210.207 24.307 < .001 ***
clarity|VVS1 5027.669 214.251 23.466 < .001 ***
clarity|IF 5265.170 233.658 22.534 < .001 ***
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
R-squared: 0.904, Adjusted R-squared: 0.904
F-statistic: 3530.024 df(8,2991), p.value < .001
Nr obs: 3,000
coefficient 2.5% 97.5% +/-
(Intercept) -6780.993 -7182.855 -6379.131 401.862
carat 8438.030 8337.834 8538.227 100.196
clarity|SI2 2790.760 2395.873 3185.646 394.886
clarity|SI1 3608.531 3215.384 4001.679 393.148
clarity|VS2 4249.906 3854.604 4645.208 395.302
clarity|VS1 4461.956 4060.801 4863.111 401.155
clarity|VVS2 5109.476 4697.311 5521.640 412.165
clarity|VVS1 5027.669 4607.574 5447.764 420.095
clarity|IF 5265.170 4807.024 5723.317 458.147</code></pre>
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" tabindex="-1"></a>pred <span class="ot"><-</span> <span class="fu">predict</span>(result, <span class="at">pred_cmd =</span> <span class="st">"carat = 1:10"</span>)</span>
<span id="cb20-2"><a href="#cb20-2" tabindex="-1"></a><span class="fu">print</span>(pred, <span class="at">n =</span> <span class="dv">10</span>)</span></code></pre></div>
<pre><code>Linear regression (OLS)
Data : diamonds
Response variable : price
Explanatory variables: carat, clarity
Interval : confidence
Prediction command : carat = 1:10
clarity carat Prediction 2.5% 97.5% +/-
SI1 1 5265.569 5174.776 5356.362 90.793
SI1 2 13703.599 13557.662 13849.536 145.937
SI1 3 22141.629 21908.326 22374.933 233.303
SI1 4 30579.660 30251.571 30907.748 328.088
SI1 5 39017.690 38592.329 39443.051 425.361
SI1 6 47455.720 46931.983 47979.458 523.738
SI1 7 55893.751 55271.056 56516.445 622.695
SI1 8 64331.781 63609.787 65053.775 721.994
SI1 9 72769.811 71948.301 73591.322 821.511
SI1 10 81207.842 80286.667 82129.017 921.175</code></pre>
<div class="sourceCode" id="cb22"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" tabindex="-1"></a><span class="fu">plot</span>(result, <span class="at">plots =</span> <span class="st">"coef"</span>)</span></code></pre></div>
<p><img src="programming_files/figure-html/regress_coeff-1.png" width="576" /></p>
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" tabindex="-1"></a><span class="fu">plot</span>(result, <span class="at">plots =</span> <span class="st">"dashboard"</span>, <span class="at">lines =</span> <span class="st">"line"</span>)</span></code></pre></div>
<p><img src="programming_files/figure-html/regress_dashboard-1.png" width="480" /></p>
<p>As another example, imagine that you want to segment a sample of
respondents based on their toothpaste attitudes. Below is the required
code to produce results using functions from the Radiant package. For
help on the commands and options for cluster analysis use
<code>?hclus</code>, <code>?plot.hclus</code>, and <code>?klus</code>.
See also the Radiant function manuals linked above.</p>
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" tabindex="-1"></a><span class="do">## run hierarchical cluster analysis on the shopping data, variables v1 through v6</span></span>
<span id="cb24-2"><a href="#cb24-2" tabindex="-1"></a>result <span class="ot"><-</span> <span class="fu">hclus</span>(shopping, <span class="st">"v1:v6"</span>)</span>
<span id="cb24-3"><a href="#cb24-3" tabindex="-1"></a></span>
<span id="cb24-4"><a href="#cb24-4" tabindex="-1"></a><span class="do">## summary - not much here - plots are more important</span></span>
<span id="cb24-5"><a href="#cb24-5" tabindex="-1"></a><span class="fu">summary</span>(result)</span></code></pre></div>
<pre><code>Hierarchical cluster analysis
Data : shopping
Variables : v1, v2, v3, v4, v5, v6
Method : ward.D
Distance : sq.euclidian
Standardize : TRUE
Observations: 20 </code></pre>
<div class="sourceCode" id="cb26"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb26-1"><a href="#cb26-1" tabindex="-1"></a><span class="do">## check the help file on how to plot results from hierarchical cluster</span></span>
<span id="cb26-2"><a href="#cb26-2" tabindex="-1"></a><span class="do">## analysis default plots</span></span>
<span id="cb26-3"><a href="#cb26-3" tabindex="-1"></a><span class="do">## it looks like there is a big jump in overall within-cluster</span></span>
<span id="cb26-4"><a href="#cb26-4" tabindex="-1"></a><span class="do">## heterogeneity in the step from 3 to 2 segments</span></span>
<span id="cb26-5"><a href="#cb26-5" tabindex="-1"></a><span class="fu">plot</span>(result)</span></code></pre></div>
<p><img src="programming_files/figure-html/hclus-1.png" width="384" /></p>
<div class="sourceCode" id="cb27"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" tabindex="-1"></a><span class="do">## show the dendrogram with cutoff at 0.05</span></span>
<span id="cb27-2"><a href="#cb27-2" tabindex="-1"></a><span class="fu">plot</span>(result, <span class="at">plots =</span> <span class="st">"dendro"</span>, <span class="at">cutoff =</span> <span class="fl">0.05</span>)</span></code></pre></div>
<p><img src="programming_files/figure-html/dendro-1.png" width="384" /></p>
<div class="sourceCode" id="cb28"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1" tabindex="-1"></a><span class="do">## plots created above suggest 3 clusters may be most appropriate</span></span>
<span id="cb28-2"><a href="#cb28-2" tabindex="-1"></a><span class="do">## use kclus to create the clusters</span></span>
<span id="cb28-3"><a href="#cb28-3" tabindex="-1"></a><span class="do">## generate output and store cluster membership</span></span>
<span id="cb28-4"><a href="#cb28-4" tabindex="-1"></a>result <span class="ot"><-</span> <span class="fu">kclus</span>(shopping, <span class="at">vars =</span> <span class="st">"v1:v6"</span>, <span class="at">nr_clus =</span> <span class="dv">3</span>)</span>
<span id="cb28-5"><a href="#cb28-5" tabindex="-1"></a><span class="fu">summary</span>(result)</span></code></pre></div>
<pre><code>K-means cluster analysis
Data : shopping
Variables : v1, v2, v3, v4, v5, v6
Clustering by: K-means
HC method : ward.D
HC distance : sq.euclidian
Standardize : TRUE
Observations : 20
Generated : 3 clusters of sizes 8 | 6 | 6
Cluster means:
v1 v2 v3 v4 v5 v6
Cluster 1 5.75 3.62 6.00 3.12 1.88 3.88
Cluster 2 1.67 3.00 1.83 3.50 5.50 3.33
Cluster 3 3.50 5.83 3.33 6.00 3.50 6.00
Percentage of within cluster heterogeneity accounted for by each cluster:
Cluster 1 40.31%
Cluster 2 25.98%
Cluster 3 33.71%
Between cluster heterogeneity accounts for 73.93% of the
total heterogeneity in the data (higher is better)</code></pre>
<div class="sourceCode" id="cb30"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb30-1"><a href="#cb30-1" tabindex="-1"></a><span class="fu">plot</span>(result, <span class="at">plots =</span> <span class="fu">c</span>(<span class="st">"density"</span>, <span class="st">"bar"</span>))</span></code></pre></div>
<p><img src="programming_files/figure-html/kclus-1.png" width="480" /></p>
<div class="sourceCode" id="cb31"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb31-1"><a href="#cb31-1" tabindex="-1"></a>shopping <span class="ot"><-</span> <span class="fu">store</span>(shopping, result, <span class="at">name =</span> <span class="st">"clus"</span>)</span>
<span id="cb31-2"><a href="#cb31-2" tabindex="-1"></a></span>
<span id="cb31-3"><a href="#cb31-3" tabindex="-1"></a><span class="do">## was the data really changed?</span></span>
<span id="cb31-4"><a href="#cb31-4" tabindex="-1"></a>shopping</span></code></pre></div>
<pre><code># A tibble: 20 × 8
id v1 v2 v3 v4 v5 v6 clus
<int> <int> <int> <int> <int> <int> <int> <fct>
1 1 6 4 7 3 2 3 1
2 2 2 3 1 4 5 4 2
3 3 7 2 6 4 1 3 1
4 4 4 6 4 5 3 6 3
5 5 1 3 2 2 6 4 2
6 6 6 4 6 3 3 4 1
7 7 5 3 6 3 3 4 1
8 8 7 3 7 4 1 4 1
9 9 2 4 3 3 6 3 2
10 10 3 5 3 6 4 6 3
11 11 1 3 2 3 5 3 2
12 12 5 4 5 4 2 4 1
13 13 2 2 1 5 4 4 2
14 14 4 6 4 6 4 7 3
15 15 6 5 4 2 1 4 1
16 16 3 5 4 6 4 7 3
17 17 4 4 7 2 2 5 1
18 18 3 7 2 6 4 3 3
19 19 4 6 3 7 2 7 3
20 20 2 3 2 4 7 2 2 </code></pre>
<p>See if you can reproduce this output in the radiant web-interface.
Start <code>Radiant</code> from the <code>Addins</code> dropdown in
Rstudio. You can also run code inside the Radiant app in the <em>Report
> R</em> tab. See
<a href="https://radiant-rstats.github.io/docs/data/code.html" target="_blank">Code</a>
page for details.</p>
© Vincent Nijs (2024) <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">
<im2024t="Creative Commons License" style="border-width: 0" src="/docs/images/by-nc-sa.png" />
</a>
<!-- some extra javascript for older browsers -->
<script type="text/javascript" src="libs/polyfill.js"></script>
<!-- mathjax -->
<!-- <script type='text/javascript' src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> -->
<script>
// manage active state of menu based on current page
$(document).ready(function () {
// active menu
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
$('a[href="' + href + '"]').parent().addClass('active');
// manage active menu header
if (href.startsWith('authoring_'))
$('a[href="' + 'authoring' + '"]').parent().addClass('active');
else if (href.endsWith('_format.html'))
$('a[href="' + 'formats' + '"]').parent().addClass('active');
else if (href.startsWith('developer_'))
$('a[href="' + 'developer' + '"]').parent().addClass('active');
});
// Google analytics
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-61296577-2', 'auto');
ga('send', 'pageview');
</script>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>