File: Getting-Started-with-the-Rcmdr.Rnw

package info (click to toggle)
rcmdr 2.9-5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,788 kB
  • sloc: makefile: 2
file content (1499 lines) | stat: -rw-r--r-- 72,701 bytes parent folder | download | duplicates (2)
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
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
\documentclass{article}%
\usepackage[round]{natbib}   % For in-text citations
\bibliographystyle{apalike} % For bibliography style
\usepackage{amsmath}%
\setcounter{MaxMatrixCols}{30}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{graphicx}
\usepackage{hyperref}

\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\topmargin}{-0.5in}
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{9in}

%\VignetteIndexEntry{Getting Started with the R Commander}

\begin{document}
\SweaveOpts{concordance=TRUE}

\title{Getting Started With the R Commander\thanks{Parts of this manual are adapted
and updated from Fox (2005). Please address correspondence to
\texttt{jfox@mcmaster.ca}. }}
\author{John Fox}
\date{Version 2.8-0 (last modified: 2024-09-30)}
\maketitle

\section{Introduction}

The\textbf{\ R Commander} \citep{Fox05, Fox17} provides a graphical user
interface (\textquotedblleft GUI\textquotedblright) to the open-source
\textbf{R } statistical computing environment \citep{RCore20}. This manual is a brief,
basic introduction to the \textbf{R Commander}; for more extensive documentation,
see \citet{Fox17}, which has a website at <\href{https://www.john-fox.ca/RCommander/}{https://www.john-fox.ca/RCommander/}> .

\textbf{R} is a command-driven system, and new users
often find learning \textbf{R} challenging. This is particularly true of those
who are new to statistical methods, such as students in basic-statistics
courses. By providing a point-and-click interface to \textbf{R}, the \textbf{R
Commander} allows these users to focus on statistical methods rather than on
remembering and formulating \textbf{R} commands. Moreover, by rendering the
generated commands visible to users, the \textbf{R Commander} has the
potential for easing the transition to writing \textbf{R} commands, at least
for some users. The \textbf{R Commander}, however, accesses only a small
fraction of the capabilities of \textbf{R} and the literally thousands of
\textbf{R} packages contributed by users to the Comprehensive R Archive
Network (CRAN). The \textbf{R Commander} is itself extensible through plug-in
packages, and many such plug-ins are now available on CRAN (see Section
\ref{sec-plugins} of this document).

This document directly describes the use of the \textbf{R Commander} under the
\textbf{Windows} version of \textbf{R}. There are small differences in the
appearance and use of the \textbf{R Commander} under \textbf{macOS} and on
\textbf{Linux} and \textbf{Unix} systems. Information about installing the
\textbf{R Commander} on these platforms is available by following the link to
the installation notes at the \textbf{R Commander} web page
<\href{https://www.john-fox.ca/RCommander/}{https://www.john-fox.ca/RCommander/}>.

I use the following typographical conventions in this document: Names of
software, such as \textbf{Windows}, \textbf{R}, the \textbf{Rcmdr} package,
and the \textbf{R Commander}, are set in \textbf{boldface} type. The names of
GUI elements such as menus, menu items, windows, and dialog boxes, are set
in \emph{italic} type. Variable names, names of data sets, and \textbf{R}
commands are set in a \texttt{typewriter font}.

\section{Starting the R Commander}

Once \textbf{R} is running, simply loading the \textbf{Rcmdr} package by
typing the command \texttt{library(Rcmdr)} into the \emph{R Console} starts
the \textbf{R Commander} graphical user interface. To function optimally under
\textbf{Windows}, the \textbf{R Commander} prefers the single-document
interface (\textquotedblleft SDI\textquotedblright) to \textbf{R}%
.\footnote{The \textbf{Windows} version of \textbf{R} is normally run from a
multiple-document interface (\textquotedblleft MDI\textquotedblright), which
contains the \emph{R Console} window, \emph{Graphical Device} windows created
during the session, and other windows related to the \textbf{R} process. In
contrast, under the single-document interface (\textquotedblleft
SDI\textquotedblright), the \emph{R Console} and \emph{Graphical Device}
windows are not contained within a master window. There are several ways to
run \textbf{R} in SDI mode --- for example, by selecting the SDI when
\textbf{R} is installed, by editing the \texttt{Rconsole} file in \textbf{R}'s
\texttt{etc} subdirectory, or by adding \texttt{-{}-sdi} to the \emph{Target}
field in the \emph{Shortcut} tab of the \textbf{R} desktop icon's
\emph{Properties}. You should be able to use the \textbf{R Commander} with the
MDI, but it will not appear within the master \textbf{R} window and arranging
the screen will be inconvenient.} After loading the package, \emph{R Console}
and \emph{R Commander} windows should appear more or less as in Figures
\ref{fig-1} and \ref{fig-1-b}.\footnote{Most of the ``screen-shots'' in this document
were produced with an earlier version of \textbf{R} and the \textbf{R Commander}.
Screen images were only updated when their appearance or content has changed.}
These and other screen images in this document
were created under \textbf{Windows 7} and \textbf{10}; if you use another version of
\textbf{Windows} (or, of course, another computing platform), then the
appearance of the screen may differ.\footnote{Notice that the \textbf{R
Commander} requires some packages in addition to several of the
\textquotedblleft recommended\textquotedblright\ packages that are normally
distributed with \textbf{R}. The \textbf{Rcmdr} package, the required
packages, and many other contributed packages are available for download from
the Comprehensive R Archive Network (CRAN) at
<\href{https://cran.r-project.org/}{https://cran.r-project.org/}>.
\par
If these packages are not installed, the \textbf{R Commander} will offer to
install them from the internet or from local files (e.g., on a CD/ROM or USB flash drive). If you
install the \textbf{Rcmdr} package via the \textbf{Windows} \textquotedblleft
R GUI,\textquotedblright\ not all of the packages on which the \textbf{Rcmdr}
package depends will be installed. You can install the \textbf{Rcmdr} package
and all of the packages on which it depends via the \texttt{install.packages}
function, setting the argument \texttt{dependencies = TRUE}, but because of
recursive dependencies, that will install more packages than are strictly
necessary for the \textbf{R Commander} to function.
\par
Thanks to Dirk Eddelbuettel, \textbf{Debian Linux} users need only issue the
command \texttt{\$ apt-get install r-cran-rcmdr} to install the \textbf{Rcmdr}
package along with all of the packages that it requires. In any event,
building and installing the \textbf{Rcmdr} package on \textbf{Linux} systems
is typically straightforward. The task is a little more complicated under
\textbf{macOS}, since the \textbf{tcltk} package on which the
\textbf{Rcmdr} depends requires that \textbf{X-Windows }be installed --- see
the \textbf{R Commander} installation notes.}%

\begin{figure}[ptb]%
\centering
\includegraphics[
height=3.4388in,
width=4.7497in
]%
{fig1.jpg}%
\caption{The \emph{R Console} window after loading the \textbf{Rcmdr}
package.}%
\label{fig-1}%
\end{figure}

\begin{figure}[ptb]%
\centering
\includegraphics[
height=5.6272in,
width=4.846in
]%
{fig-1-b.jpg}%
\caption{The \emph{R Commander} window at start-up.}%
\label{fig-1-b}%
\end{figure}

The \emph{R Commander} and \emph{R Console} windows float freely on the
desktop. You will normally use the \textbf{R Commander}'s menus and dialog
boxes to read, manipulate, and analyze data, and you can safely minimize the
\emph{R Console} window.

\begin{itemize}
\item \textbf{R} commands generated by the \textbf{R Commander} GUI appear in
the \emph{R Script} tab in the upper pane of the main \emph{R Commander}
window. You can also type \textbf{R} commands directly into the script
pane;\footnote{You can also type commands at the \texttt{$>$} (greater-than) prompt
in the \emph{R Console}, but output generated by these
commands will not appear in the \textbf{R Commander} \emph{Output} pane and
error and warning messages will normally not be visible.} the main purpose of
the \textbf{R Commander}, however, is to avoid having to type commands. The
second tab in the upper pane (labelled \emph{R Markdown}) also accumulates the
commands produced by the\textbf{\ R Commander} and can be used to generate
printed reports; the \emph{R Markdown} tab is described in Section
\ref{sec-markdown}.

\item Printed output appears by default in the second pane (labelled
\emph{Output}).

\item The lower, gray pane (labelled \emph{Messages}) displays error messages,
warnings, and some other information (\textquotedblleft
notes\textquotedblright), such as the start-up message in Figure \ref{fig-1-b}.

\item When you create graphs, these will appear in a separate \emph{Graphics
Device} window.
\end{itemize}

There are several menus along the top of the \emph{R Commander} window:

\begin{description}
\item[File] Menu items for loading and saving script files; for saving output
and the \textbf{R} workspace; and for exiting.

\item[Edit] Menu items (\emph{Cut}, \emph{Copy}, \emph{Paste}, etc.) for
editing text in the various panes and tabs. Right-clicking in one of these
panes or tabs also brings up an edit \textquotedblleft
context\textquotedblright\ menu.

\item[Data] Submenus containing menu items for reading and manipulating data.

\item[Statistics] Submenus containing menu items for a variety of statistical analyses.

\item[Graphs] Menu items for creating various statistical graphs.

\item[Models] Menu items and submenus for obtaining numerical summaries,
confidence intervals, hypothesis tests, diagnostics, and graphs for a
statistical model, and for adding diagnostic quantities, such as residuals, to
the data set.

\item[Distributions] Submenus to obtain cumulative probabilities, probability
densities or masses, quantiles, and graphs of standard statistical
distributions (to be used, for example, as a substitute for statistical
tables), and to generate samples from these distributions.

\item[Tools] Menu items for loading \textbf{R} packages unrelated to the
\textbf{Rcmdr} package (e.g., to access data saved in another package); for
loading \textbf{Rcmdr} plug-in packages (see \citealp{Fox17}, \citealp{Fox07}, \citealp{FoxCarvalho12},
and Section~\ref{sec-plugins} below);
for setting most\textbf{\ R Commander} options and for
saving options so that they will be applied in subsequent sessions; and for
installing optional auxiliary software (see Section~\ref{sec-markdown}).

\item[Help] Menu items to obtain information about the \textbf{R Commander}
(including this manual) and associated software. As well, each \textbf{R
Commander} dialog box has a \emph{Help} button (see below).
\end{description}

The complete menu \textquotedblleft tree\textquotedblright\ for the \textbf{R
Commander} (version 2.8-0) is shown below. Most menu items lead to dialog
boxes, as illustrated later in this manual, and, as is conventional, such menu items are followed by \texttt{...}.
Menu items are inactive
(\textquotedblleft grayed out\textquotedblright) if they are inapplicable to
the current context. For example, if a data set contains no factors
(categorical variables), the menu items for contingency tables will be
inactive.\footnote{Some menu items may not be displayed in certain
circumstances. For example, the \textbf{knitr} menu items in the
\emph{File} menu will be displayed only if the \emph{knitr} tab is
activated, and the \emph{Install auxiliary software} item in the \emph{Tools}
menu is activated only if the optional \LaTeX{} or \textbf{Pandoc} software
are missing. The menus also include dividers, which are not shown here.}

<<echo=F>>=
Sys.setenv(LANGUAGE='en')
Sys.setLanguage("en")
library('Rcmdr')
gm <- function(x) {
  gettext(paste0(x, '...'), domain='R-Rcmdr')
  }
gt <- function(x) {
  gettext(x, domain='R-Rcmdr')
  }
@
\begin{verbatim}
\Sexpr{gt('File')}
 |- \Sexpr{gm('Change working directory')}
 |- \Sexpr{gm('Open script file')}
 |- \Sexpr{gm('Save script')}
 |- \Sexpr{gm('Save script as')}
 |- \Sexpr{gm('Open R Markdown file')}
 |- \Sexpr{gm('Save R Markdown file')}
 |- \Sexpr{gm('Save R Markdown file as')}
 |- \Sexpr{gm('Save output')}
 |- \Sexpr{gm('Save output as')}
 |- \Sexpr{gm('Save R workspace')}
 |- \Sexpr{gm('Save R workspace as')}
 |- \Sexpr{gt('Exit')}
 | |- \Sexpr{gt('From Commander')}
 | |- \Sexpr{gt('From Commander and R')}
 | |- \Sexpr{gt('Restart the Commander')}
\Sexpr{gt('Edit')}
 |- \Sexpr{gt('Edit R Markdown document')}
 |- \Sexpr{gt('Edit knitr document')}
 |- \Sexpr{gt('Remove last Markdown command block')}
 |- \Sexpr{gt('Remove last Markdown section title')}
 |- \Sexpr{gt('Remove last knitr command block')}
 |- \Sexpr{gt('Cut')}
 |- \Sexpr{gt('Copy')}
 |- \Sexpr{gt('Paste')}
 |- \Sexpr{gt('Delete')}
 |- \Sexpr{gt('Find')}
 |- \Sexpr{gt('Select all')}
 |- \Sexpr{gt('Undo')}
 |- \Sexpr{gt('Redo')}
 |- \Sexpr{gt('Clear window')}
\Sexpr{gt('Data')}
 |- \Sexpr{gm('New data set')}
 |- \Sexpr{gm('Load data set')}
 |- \Sexpr{gm('Merge data sets')}
 |- \Sexpr{gt('Import data')}
 | |- \Sexpr{gm('from text file, clipboard, or URL')}
 | |- \Sexpr{gm('from SPSS data set')}
 | |- \Sexpr{gm('from SAS xport file')}
 | |- \Sexpr{gm('from SAS b7dat file')}
 | |- \Sexpr{gm('from Minitab data set')}
 | |- \Sexpr{gm('from STATA data set')}
 | |- \Sexpr{gm('from Excel file')}
 |- \Sexpr{gt('Data in packages')}
 | |- \Sexpr{gt('List data sets in packages')}
 | |- \Sexpr{gm('Read data set from an attached package')}
 |- \Sexpr{gt('Active data set')}
 | |- \Sexpr{gm('View data')}
 | |- \Sexpr{gm('Select active data set')}
 | |- \Sexpr{gt('Refresh active data set')}
 | |- \Sexpr{gt('Help on active data set (if available)')}
 | |- \Sexpr{gt('Variables in active data set')}
 | |- \Sexpr{gm('Set case names')}
 | |- \Sexpr{gm('Subset active data set')}
 | |- \Sexpr{gm('Sort active data set')}
 | |- \Sexpr{gm('Aggregate variables in active data set')}
 | |- \Sexpr{gm('Select row(s) from active data set')}
 | |- \Sexpr{gm('Remove row(s) from active data set')}
 | |- \Sexpr{gm('Stack variables in active data set')}
 | |- \Sexpr{gm('Remove cases with missing data')}
 | |- \Sexpr{gm('Reshape data set from long to wide format')}
 | |- \Sexpr{gm('Reshape data set from wide to long format')}
 | |- \Sexpr{gm('Convert all character variables to factors')}
 | |- \Sexpr{gm('Save active data set')}
 | |- \Sexpr{gm('Export active data set')}
 |- \Sexpr{gt('Manage variables in active data set')}
 | |- \Sexpr{gm('Recode variables')}
 | |- \Sexpr{gm('Compute new variable')}
 | |- \Sexpr{gt('Add observation numbers to data set')}
 | |- \Sexpr{gm('Standardize variables')}
 | |- \Sexpr{gm('Convert numeric variables to factors')}
 | |- \Sexpr{gm('Convert character variables to factors')}
 | |- \Sexpr{gm('Bin numeric variable')}
 | |- \Sexpr{gm('Reorder factor levels')}
 | |- \Sexpr{gm('Drop unused factor levels')}
 | |- \Sexpr{gm('Define contrasts for a factor')}
 | |- \Sexpr{gm('Rename variables')}
 | |- \Sexpr{gm('Delete variables from data set ')}
\Sexpr{gt('Statistics')}
 |- \Sexpr{gt('Summaries')}
 | |- \Sexpr{gt('Active data set')}
 | |- \Sexpr{gm('Numerical summaries')}
 | |- \Sexpr{gm('Frequency distributions')}
 | |- \Sexpr{gt('Count missing observations')}
 | |- \Sexpr{gm('Table of statistics')}
 | |- \Sexpr{gm('Correlation matrix')}
 | |- \Sexpr{gm('Correlation test')}
 | |- \Sexpr{gm('Test of normality')}
 | |- \Sexpr{gm('Transform toward normality')}
 |-\Sexpr{gt('Contingency tables')}
 | |- \Sexpr{gm('Two-way table')}
 | |- \Sexpr{gm('Multi-way table')}
 | |- \Sexpr{gm('Enter and analyze two-way table')}
 |- \Sexpr{gt('Means')}
 | |- \Sexpr{gm('Single-sample t-test')}
 | |- \Sexpr{gm('Independent samples t-test')}
 | |- \Sexpr{gm('Paired t-test')}
 | |- \Sexpr{gm('One-way ANOVA')}
 | |- \Sexpr{gm('Multi-way ANOVA')}
 | |- \Sexpr{gm('One-factor repeated-measures ANOVA/ANCOVA')}
 | |- \Sexpr{gm('Two-factor repeated-measures ANOVA/ANCOVA')}
 |- \Sexpr{gt('Proportions')}
 | |- \Sexpr{gm('Single-sample proportion test')}
 | |- \Sexpr{gm('Two-sample proportions test')}
 |- \Sexpr{gt('Variances')}
 | |- \Sexpr{gm('Two-variances F-test')}
 | |- \Sexpr{gm('Bartlett\'s test')}
 | |- \Sexpr{gm('Levene\'s test')}
 |- \Sexpr{gt('Nonparametric tests')}
 | |- \Sexpr{gm('Two-sample Wilcoxon test')}
 | |- \Sexpr{gm('Single-sample Wilcoxon test')}
 | |- \Sexpr{gm('Paired-samples Wilcoxon test')}
 | |- \Sexpr{gm('Kruskal-Wallis test')}
 | |- \Sexpr{gm('Friedman rank-sum test')}
 |- \Sexpr{gt('Dimensional analysis')}
 | |- \Sexpr{gm('Scale reliability')}
 | |- \Sexpr{gm('Principal-components analysis')}
 | |- \Sexpr{gm('Factor analysis')}
 | |- \Sexpr{gm('Confirmatory factor analysis')}
 | |- \Sexpr{gt('Cluster analysis')}
 | | |- \Sexpr{gm('k-means cluster analysis')}
 | | |- \Sexpr{gm('Hierarchical cluster analysis')}
 | | |- \Sexpr{gm('Summarize hierarchical clustering')}
 | | |- \Sexpr{gm('Add hierarchical clustering to data set')}
 |- \Sexpr{gt('Fit models')}
 | |- \Sexpr{gm('Linear regression')}
 | |- \Sexpr{gm('Linear model')}
 | |- \Sexpr{gm('Generalized linear model')}
 | |- \Sexpr{gm('Multinomial logit model')}
 | |- \Sexpr{gm('Ordinal regression model')}
 | |- \Sexpr{gm('Linear mixed model')}
 | |- \Sexpr{gm('Generalized linear mixed model')}
\Sexpr{gt('Graphs')}
 |- \Sexpr{gm('Color palette')}
 |- \Sexpr{gm('Index plot')}
 |- \Sexpr{gm('Dot plot')}
 |- \Sexpr{gm('Histogram')}
 |- \Sexpr{gm('Plot discrete numeric variable...')}
 |- \Sexpr{gm('Density estimate')}
 |- \Sexpr{gm('Stem-and-leaf display')}
 |- \Sexpr{gm('Boxplot')}
 |- \Sexpr{gm('Quantile-comparison plot')}
 |- \Sexpr{gm('Symmetry boxplot')}
 |- \Sexpr{gm('Scatterplot')}
 |- \Sexpr{gm('Scatterplot matrix')}
 |- \Sexpr{gm('Line graph')}
 |- \Sexpr{gm('XY conditioning plot')}
 |- \Sexpr{gm('Plot of means')}
 |- \Sexpr{gm('Strip chart')}
 |- \Sexpr{gm('Bar graph')}
 |- \Sexpr{gm('Pie chart')}
 |- \Sexpr{gt('3D graph')}
 | |- \Sexpr{gm('3D scatterplot')}
 | |- \Sexpr{gt('Identify observations with mouse')}
 | |- \Sexpr{gt('Save graph to file')}
 |- \Sexpr{gt('Save graph to file')}
 | |- \Sexpr{gm('as bitmap')}
 | |- \Sexpr{gm('as PDF/Postscript/EPS')}
 | |- \Sexpr{gm('3D RGL graph')}
\Sexpr{gt('Models')}
 |- \Sexpr{gm('Select active model')}
 |- \Sexpr{gt('Summarize model')}
 |- \Sexpr{gm('Compare model coefficients')}
 |- \Sexpr{gm('Add observation statistics to data')}
 |- \Sexpr{gt('Akaike Information Criterion (AIC)')}
 |- \Sexpr{gt('Bayesian Information Criterion (BIC)')}
 |- \Sexpr{gm('Stepwise model selection')}
 |- \Sexpr{gm('Subset model selection')}
 |- \Sexpr{gm('Confidence intervals...')}
 |- \Sexpr{gm('Bootstrap confidence intervals')}
 |- \Sexpr{gm('Delta method confidence interval')}
 |- \Sexpr{gt('Hypothesis tests')}
 | |- \Sexpr{gm('ANOVA table')}
 | |- \Sexpr{gm('Compare two models')}
 | |- \Sexpr{gm('Linear hypothesis')}
 |- \Sexpr{gt('Numerical diagnostics')}
 | |- \Sexpr{gt('Variance-inflation factors')}
 | |- \Sexpr{gm('Breusch-Pagan test for heteroscedasticity')}
 | |- \Sexpr{gm('Durbin-Watson test for autocorrelation')}
 | |- \Sexpr{gm('RESET test for nonlinearity')}
 | |- \Sexpr{gt('Bonferroni outlier test')}
 | |- \Sexpr{gt('Response transformation')}
 |- \Sexpr{gt('Graphs')}
 | |- \Sexpr{gt('Basic diagnostic plots')}
 | |- \Sexpr{gm('Residual quantile-comparison plot')}
 | |- \Sexpr{gm('Component+residual plots')}
 | |- \Sexpr{gm('3D component+residual plot')}
 | |- \Sexpr{gm('Added-variable plots')}
 | |- \Sexpr{gm('3D added-variable plot')}
 | |- \Sexpr{gm('Influence plot')}
 | |- \Sexpr{gm('Influence index plot')}
 | |- \Sexpr{gm('Effect plots')}
 | |- \Sexpr{gm('Predictor effect plots')}
\Sexpr{gt('Distributions')}
 |- \Sexpr{gm('Set random number generator seed')}
 |- \Sexpr{gt('Continuous distributions')}
 | |- \Sexpr{gt('Normal distribution')}
 | | |- \Sexpr{gm('Normal quantiles')}
 | | |- \Sexpr{gm('Normal probabilities')}
 | | |- \Sexpr{gm('Plot normal distribution')}
 | | |- \Sexpr{gm('Sample from normal distribution')}
 | |- \Sexpr{gt('t distribution')}
 | | |- \Sexpr{gm('t quantiles')}
 | | |- \Sexpr{gm('t probabilities')}
 | | |- \Sexpr{gm('Plot t distribution')}
 | | |- \Sexpr{gm('Sample from t distribution')}
 | |- \Sexpr{gt('Chi-squared distribution')}
 | | |- \Sexpr{gm('Chi-squared quantiles')}
 | | |- \Sexpr{gm('Chi-squared probabilities')}
 | | |- \Sexpr{gm('Plot chi-squared distribution')}
 | | |- \Sexpr{gm('Sample from chi-squared distribution')}
 | |- \Sexpr{gt('F distribution')}
 | | |- \Sexpr{gm('F quantiles')}
 | | |- \Sexpr{gm('F probabilities')}
 | | |- \Sexpr{gm('Plot F distribution')}
 | | |- \Sexpr{gm('Sample from F distribution')}
 | |- \Sexpr{gt('Exponential distribution')}
 | | |- \Sexpr{gm('Exponential quantiles')}
 | | |- \Sexpr{gm('Exponential probabilities')}
 | | |- \Sexpr{gm('Plot exponential distribution')}
 | | |- \Sexpr{gm('Sample from exponential distribution')}
 | |- \Sexpr{gt('Uniform distribution')}
 | | |- \Sexpr{gm('Uniform quantiles')}
 | | |- \Sexpr{gm('Uniform probabilities')}
 | | |- \Sexpr{gm('Plot uniform distribution')}
 | | |- \Sexpr{gm('Sample from uniform distribution')}
 | |- \Sexpr{gt('Beta distribution')}
 | | |- \Sexpr{gm('Beta quantiles')}
 | | |- \Sexpr{gm('Beta probabilities')}
 | | |- \Sexpr{gm('Plot beta distribution')}
 | | |- \Sexpr{gm('Sample from beta distribution')}
 | |- \Sexpr{gt('Cauchy distribution')}
 | | |- \Sexpr{gm('Cauchy quantiles')}
 | | |- \Sexpr{gm('Cauchy probabilities')}
 | | |- \Sexpr{gm('Plot Cauchy distribution')}
 | | |- \Sexpr{gm('Sample from Cauchy distribution')}
 | |- \Sexpr{gt('Logistic distribution')}
 | | |- \Sexpr{gm('Logistic quantiles')}
 | | |- \Sexpr{gm('Logistic probabilities')}
 | | |- \Sexpr{gm('Plot logistic distribution')}
 | | |- \Sexpr{gm('Sample from logistic distribution')}
 | |- \Sexpr{gt('Lognormal distribution')}
 | | |- \Sexpr{gm('Lognormal quantiles')}
 | | |- \Sexpr{gm('Lognormal probabilities')}
 | | |- \Sexpr{gm('Plot lognormal distribution')}
 | | |- \Sexpr{gm('Sample from lognormal distribution')}
 | |- \Sexpr{gt('Gamma distribution')}
 | | |- \Sexpr{gm('Gamma quantiles')}
 | | |- \Sexpr{gm('Gamma probabilities')}
 | | |- \Sexpr{gm('Plot gamma distribution')}
 | | |- \Sexpr{gm('Sample from gamma distribution')}
 | |- \Sexpr{gt('Weibull distribution')}
 | | |- \Sexpr{gm('Weibull quantiles')}
 | | |- \Sexpr{gm('Weibull probabilities')}
 | | |- \Sexpr{gm('Plot Weibull distribution')}
 | | |- \Sexpr{gm('Sample from Weibull distribution')}
 | |- \Sexpr{gt('Gumbel distribution')}
 | | |- \Sexpr{gm('Gumbel quantiles')}
 | | |- \Sexpr{gm('Gumbel probabilities')}
 | | |- \Sexpr{gm('Plot Gumbel distribution')}
 | | |- \Sexpr{gm('Sample from Gumbel distribution')}
 |- \Sexpr{gt('Discrete distributions')}
 | |- \Sexpr{gt('Binomial distribution')}
 | | |- \Sexpr{gm('Binomial quantiles')}
 | | |- \Sexpr{gm('Binomial tail probabilities')}
 | | |- \Sexpr{gm('Binomial probabilities')}
 | | |- \Sexpr{gm('Plot binomial distribution')}
 | | |- \Sexpr{gm('Sample from binomial distribution')}
 | |- \Sexpr{gt('Poisson distribution')}
 | | |- \Sexpr{gm('Poisson quantiles')}
 | | |- \Sexpr{gm('Poisson tail probabilities')}
 | | |- \Sexpr{gm('Poisson probabilities')}
 | | |- \Sexpr{gm('Plot Poisson distribution')}
 | | |- \Sexpr{gm('Sample from Poisson distribution')}
 | |- \Sexpr{gt('Geometric distribution')}
 | | |- \Sexpr{gm('Geometric quantiles')}
 | | |- \Sexpr{gm('Geometric tail probabilities')}
 | | |- \Sexpr{gm('Geometric probabilities')}
 | | |- \Sexpr{gm('Plot geometric distribution')}
 | | |- \Sexpr{gm('Sample from geometric distribution')}
 | |- \Sexpr{gt('Hypergeometric distribution')}
 | | |- \Sexpr{gm('Hypergeometric quantiles')}
 | | |- \Sexpr{gm('Hypergeometric tail probabilities')}
 | | |- \Sexpr{gm('Hypergeometric probabilities')}
 | | |- \Sexpr{gm('Plot hypergeometric distribution')}
 | | |- \Sexpr{gm('Sample from hypergeometric distribution')}
 | |- \Sexpr{gt('Negative binomial distribution')}
 | | |- \Sexpr{gm('Negative binomial quantiles')}
 | | |- \Sexpr{gm('Negative binomial tail probabilities')}
 | | |- \Sexpr{gm('Negative binomial probabilities')}
 | | |- \Sexpr{gm('Plot negative binomial distribution')}
 | | |- \Sexpr{gm('Sample from negative binomial distribution')}
\Sexpr{gt('Tools')}
 |- \Sexpr{gm('Load package(s)')}
 |- \Sexpr{gm('Load Rcmdr plug-in(s)')}
 |- \Sexpr{gm('Options')}
 |- \Sexpr{gm('Save Rcmdr options')}
 |- \Sexpr{gm('Manage Mac OS X app nap for R.app')}
 |- \Sexpr{gm('Install auxiliary software')}
\Sexpr{gt('Help')}
 |- \Sexpr{gt('Commander help')}
 |- \Sexpr{gt('Introduction to the R Commander')}
 |- \Sexpr{gt('R Commander website')}
 |- \Sexpr{gt('About Rcmdr')}
 |- \Sexpr{gt('R Commander hex sticker')}
 |- \Sexpr{gt('Help on active data set (if available)')}
 |- \Sexpr{gt('Start R help system')}
 |- \Sexpr{gt('R website')}
 |- \Sexpr{gt('Using R Markdown')}
\end{verbatim}

The \textbf{R Commander} interface includes a few elements in addition to
menus and dialogs:

\begin{itemize}
\item Below the menus is a \textquotedblleft toolbar\textquotedblright\ with a
row of buttons.

\begin{itemize}
\item The left-most (flat) button shows the name of the active data set.
Initially there is no active data set. If you press this button, you will be
able to choose among data sets currently in memory (if there is more than
one). Most of the menus and dialogs in the \textbf{R Commander} reference the
active data set. (The \emph{File}, \emph{Edit}, and \emph{Distributions} menus
are exceptions.)

\item Two buttons allow you to open the \textbf{R Commander} data editor to modify the
active data set or a viewer to examine it.\footnote{By default, the \textbf{R Commander} data editor
is used if the number of values (cells) in the data set is 10,000 or fewer; for larger data sets,
the standard \textbf{R} editor is used. See the \textbf{R Commander} help for information
on resetting this threshold.} The data-set viewer can remain open
while other operations are performed, and the view is refreshed if the data set is modified, for example
by adding a variable.\footnote{The data viewer, provided by
the \texttt{showData} function from David Firth's \textbf{relimp}
package \citep{Firth16}, can be slow for data sets with large numbers of
variables. When the number of variables exceeds 100 or the number of cases exceeds 20,000,
the less aesthetically pleasing \textbf{R} \texttt{View} command is used
instead to display the data set. To use \texttt{View} regardless of the number
of variables or cases, set these thresholds to 0. See the \textbf{R Commander} help for
details.}

\item A flat button indicates the name of the active statistical model --- a
linear model (such as a linear-regression model), a generalized linear model,
a multinomial logit model,  an ordinal regression model, or a linear or generalized linear mixed-effects model.\footnote{\textbf{R
Commander} plug-in packages (\citealp{Fox17}; \citealp{Fox07}; \citealp{FoxCarvalho12}) may provide
additional classes of models.} Initially there is no active model. If there is
more than one model in memory associated with the active data set, you can
choose among the models by pressing the button. The \textbf{R Commander}
synchronizes models and the data sets to which they are fit.
\end{itemize}

\item Immediately below the toolbar is a pane containing the \emph{R Script}
tab, a large scrollable text window. As mentioned, commands generated by the
\textbf{R Commander} are copied into this window. You can edit the text in the
\emph{Script} tab or even type your own \textbf{R} commands into the window.
Pressing the \emph{Submit} button, which is at the right below the
\emph{Script} tab (or, alternatively, the key combination \emph{Ctrl-r}%
,\footnote{That is, hold down the \emph{Ctrl} (or \emph{Control}) key and
simultaneously press the \emph{r} key. On \textbf{macOS} you can usually substitute
the \emph{Command} key for the \emph{Control} key, both here and more generally,
but \emph{Control} key combinations can be used as well.} for \textquotedblleft
run,\textquotedblright\ or\emph{\ Ctrl-Tab}), causes the line containing the
cursor to be submitted (or resubmitted) for execution. If several lines are
selected (e.g., by left-clicking and dragging the mouse over them), then
pressing \emph{Submit} will cause all of them to be executed. Commands entered
into the \emph{R Script} tab can extend over more than one line, but all lines
must be submitted simultaneously. The key combination \emph{Ctrl-a} selects
all of the text in the \emph{Script} tab, and \emph{Ctrl-s} brings up a dialog
box to save the contents of the tab. The \emph{R Markdown} tab is described in
Section \ref{sec-markdown}.

\item Below the \emph{R Script} and \emph{R Markdown} tabs is a pane
containing a large scrollable and editable text window for \emph{Output}.
Commands echoed to the \emph{Output} pane appear in red, the resulting output
in dark blue (as in the\ standard \textbf{Windows} \emph{R Console}).

\item At the bottom is a small gray pane for \emph{Messages}. Error messages
are displayed in red text, warnings in green, and other messages in dark blue.
Errors and warnings also provide an audible cue by ringing a bell.
\end{itemize}

As mentioned, once you have loaded the \textbf{Rcmdr} package, you can
minimize the \emph{R Console}. The \emph{R Commander} window can also be
resized or maximized in the normal manner. If you resize the \textbf{R
Commander}, the width of subsequent \textbf{R} output is automatically
adjusted to fit the \emph{Output} pane.

The \textbf{R Commander} is highly configurable: I have described the default
configuration here. Changes to the configuration can be made via the
\emph{Tools }$\longrightarrow$\emph{\ Options\ldots}\ menu, or --- more
extensively --- by setting \textbf{R Commander }options in \textbf{R}%
.\footnote{A menu item that terminates in ellipses (i.e., three dots, ...)
leads to a dialog box; this is a standard GUI convention. In this document,
$\longrightarrow$ represents selecting a menu item or submenu from a menu.}
See \emph{Help }$\longrightarrow$\emph{\ Commander help} for details.

\section{Data Input}

Most of the procedures in the \textbf{R Commander} assume that there is an
active data set.\footnote{Procedures selected under via the
\emph{Distributions} menu are exceptions, as is \emph{Enter and analyze
two-way table...} under the \emph{Statistics }$\longrightarrow$%
\emph{\ Contingency tables} menu.} If there are several data sets in memory,
you can choose among them, but only one is active. When the \textbf{R
Commander} starts up, there is no active data set.

The \textbf{R Commander} provides several ways to get data into \textbf{R}:

\begin{itemize}
\item Using the \textbf{R Commander} data editor, You can enter data directly
via \emph{Data }$\longrightarrow$\emph{\ New data set...}. This is a
reasonable choice only for a very small data set.

\item You can import data from a plain-text (\textquotedblleft
ascii\textquotedblright) file or the clipboard, over the internet from a URL,
from another statistical package (\textbf{Minitab}, \textbf{SPSS},
\textbf{SAS}, or \textbf{Stata}), or from an \textbf{Excel} spreadsheet.

\item You can read a data set that is included in an \textbf{R} package,
either typing the name of the data set (if you know it), or selecting the data
set in a dialog box.
\end{itemize}

\subsection{Reading Data From a Text File}

For example, consider the data file \texttt{Nations.txt}.\footnote{This file
resides in the \texttt{etc} subdirectory of the \textbf{Rcmdr} package. The
data are for 1998 and are from the United Nations.} The first few lines of the
file are as follows:
\begin{verbatim}
TFR contraception infant.mortality GDP region
Afghanistan                 6.90    NA  154  2848   Asia
Albania                     2.60    NA   32   863   Europe
Algeria                     3.81    52   44  1531   Africa
American-Samoa              NA      NA   11  NA     Oceania
Andorra                     NA      NA  NA   NA     Europe
Angola                      6.69    NA  124   355   Africa
Antigua                     NA      53   24  6966   Americas
Argentina                   2.62    NA   22  8055   Americas
Armenia                     1.70    22   25   354   Europe
Australia                   1.89    76    6 20046   Oceania
. . .

\end{verbatim}

\begin{itemize}
\item The first line of the file contains variable names: \texttt{TFR} (the
total fertility rate, expressed as number of children per woman),
\texttt{contraception} (the rate of contraceptive use among married women, in
percent), \texttt{infant.mortality} (the infant-mortality rate per 1000 live
births), \texttt{GDP} (gross domestic product per capita, in U.S. dollars),
and \texttt{region}.

\item Subsequent lines contain the data values themselves, one line per
country. The data values are separated by \textquotedblleft white
space\textquotedblright\ --- one or more blanks or tabs. Although it is
helpful to make the data values line up vertically, it is not necessary to do
so. Notice that the data lines begin with the country names. Because I want
these to be the \textquotedblleft row names\textquotedblright\ for the data
set, there is no corresponding variable name: That is, there are five variable
names but six data values on each line, the first of which is alphabetic. When
this happens, the \textbf{R} \texttt{read.table} command will interpret the
first value on each line as the row name.

\item Some of the data values are missing. In \textbf{R}, it is most
convenient to use \texttt{NA} (representing \textquotedblleft not
available\textquotedblright) to encode missing data, as I have done here.

\item The variables \texttt{TFR}, \texttt{contraception},
\texttt{infant.mortality}, and \texttt{GDP} are numeric (quantitative)
variables; in contrast, \texttt{region} contains region names. When the data
are read, \textbf{R} will treat \texttt{region} as a \textquotedblleft
factor\textquotedblright\ --- that is, as a categorical variable. In most
contexts, the \textbf{R Commander} distinguishes between numerical variables
and factors, and will try to prevent you from doing unreasonable things, such
as computing the mean of a factor.\footnote{Character varaibles, whose values are character strings, and logical variables, whose values are \texttt{TRUE} or \texttt{FALSE} are treated as factors by the \textbf{R Commander}.}
\end{itemize}

To read the \texttt{Nations.txt} data file into \textbf{R}, select \emph{Data
}$\longrightarrow$\emph{\ Import data }$\longrightarrow$\emph{\ from text
file, clipboard, or URL...} from the \emph{R Commander} menus. This operation
brings up a \emph{Read Text Data} dialog, as shown in Figure \ref{fig-2}. The
default name of the data set is \texttt{Dataset}. I have changed the name to
\texttt{Nations}.

\begin{figure}[ptb]%
\centering
\includegraphics[
height=3.6961in,
width=3.9535in
]%
{fig-2.jpg}%
\caption{Reading data from a text file.}%
\label{fig-2}%
\end{figure}

\begin{figure}[ptb]%
\centering
\includegraphics[
height=5.0203in,
width=6.8709in
]%
{fig-2b.jpg}%
\caption{Open-file dialog for reading a text data file.}%
\label{fig-2b}%
\end{figure}


Valid \textbf{R} names begin with an upper- or lower-case letter (or a period,
\texttt{.}) and consist entirely of letters, periods, underscores
(\texttt{\_}), and numerals (i.e., \texttt{0}--\texttt{9}); in particular, do
not include any embedded blanks in a data-set name. \textbf{R} is
case-sensitive, and so, for example, \texttt{nations}, \texttt{Nations}, and
\texttt{NATIONS} are distinguished, and could be used to represent different
data sets.

Clicking the \emph{OK} button in the \emph{Read Text Data} dialog brings up an
\emph{Open }file dialog, shown in Figure \ref{fig-2b}. Here I navigated to
and selected the file \texttt{Nations.txt}. Clicking the \emph{Open} button in
the dialog causes the data file to be read. Once the data file is read, it
becomes the active data set in the \textbf{R Commander}. As a consequence, in
Figure \ref{fig-3}, the name of the data set appears in the data set button
near the top left of the \emph{R Commander} window. The command to read the
\texttt{Nations} data set (the \textbf{R} \texttt{read.table} command) appears in the \emph{R Script} tab and
\emph{Output} pane. As well, when the data set is read and becomes the active
data set, a note appears in the \emph{Messages} pane.

I next clicked the \emph{View data set} button to bring up the data viewer
window, also shown in Figure \ref{fig-3}.

\begin{figure}[ptb]%
\centering
\includegraphics[
width=6.3in
]%
{fig-3.jpg}%
\caption{Displaying the active data set.}%
\label{fig-3}%
\end{figure}

The \texttt{read.table} command creates an \textbf{R} \textquotedblleft data
frame,\textquotedblright\ which is an object containing a rectangular
cases-by-variables data set: The rows of the data set represent cases or
observations and the columns represent variables. Data sets in the \textbf{R
Commander} are \textbf{R} data frames.

\subsection{Entering Data Directly}

You can enter data directly into the
\textbf{R Commander} basic spreadsheet-like data editor. A simple
alternative, which I in fact prefer, is to save the data in a plain-text file
(be careful, if you create the data file with a word processor, to save it as
a plain-text or \textquotedblleft ascii\textquotedblright\ file), typically
with file type \texttt{.txt}, and then to read the file as in the preceding
section, via \emph{Data }$\longrightarrow$\emph{\ Import data }%
$\longrightarrow$\emph{\ from text file, clipboard, or URL...} . If your data
are already in a spreadsheet program, such as \textbf{Excel}, you can simply
export the data to a comma-separated-values text file (\texttt{.csv} file),
and read the file into the R Commander, being careful to specify the
field separator as a comma. Recall that you can also
read an \textbf{Excel} spreadsheet directly.

As an example of direct data input, I use a very small data set from Problem
2.44 in \citet{Moore00}:

\begin{itemize}
\item Select \emph{Data }$\longrightarrow$\emph{\ New data set...} from the
\emph{R Commander} menus. Optionally enter a name for the data set, such as
\texttt{Problem2.44}, in the resulting dialog box, and click the \emph{OK}
button. (Remember that \textbf{R} names cannot include embedded blanks.) This
will bring up a \emph{Data Editor} window with an empty data set.

\item Enter the data from the problem into the first two columns of the data
editor. Add a column by clicking the \emph{Add column} button in the data editor
toolbar, or by selecting \emph{Add column} from the \emph{Edit} menu. Similarly,
add rows to the data set by clicking the \emph{Add row} button repeatedly or via
the \emph{Edit} menu. You can also add a row by pressing the \emph{Enter} key
or add a column by pressing the \emph{Tab} key when the cursor is in a cell in the data table.


\item You can move from one cell to another by using the arrow keys on your
keyboard or by pointing with the mouse and left-clicking. Originally, the
variables are named \texttt{var1} and \texttt{var2}, and the data values are
all \texttt{NA} (i.e., missing). When you type a new
variable name, row name, or data value into a cell of the data editor, the new value replaces what was
previously there. If you double-click in a cell, then the cell becomes \texttt{NA}.
When you are finished entering the data, the data-editor window should look like Figure \ref{fig-4}.%

\item In this example, both variables are numeric. If you type any non-numeric values in a column
in the data editor (other than the missing value \texttt{NA}), then the column will define a factor
(categorical variable) in the new data set.

\begin{figure}[ptb]%
\centering
\includegraphics[
width=3in,
]%
{fig-4.jpg}%
\caption{Data editor after the data are entered.}%
\label{fig-4}%
\end{figure}


\item Select \emph{File }$\longrightarrow$\emph{Exit and save} from the \emph{Data
Editor} menus or click the \emph{OK}
button. The data set that you entered is now the active data set in
the \textbf{R Commander}.
\end{itemize}

\subsection{Reading Data from a Package\label{sec-data-in-packages}}

Many \textbf{R} packages include data. Data sets in packages can be listed in
a pop-up window via \emph{Data }$\longrightarrow$\emph{\ Data in packages
}$\longrightarrow$\emph{\ List data sets in packages}, and can be read into
the \textbf{R Commander} via \emph{Data }$\longrightarrow$\emph{\ Data in
packages }$\longrightarrow$\emph{\ Read data set from an attached
package}.\footnote{Not all data in packages are data frames but only data
frames are suitable for use in the \textbf{R Commander}. If you attempt to read
data that are not in a data frame, the \textbf{R Commander} will try to change them
into a data frame, printing a warning message if it's successful and an error message if it's not.}
The resulting dialog box is shown in Figure \ref{fig-6-5}.\footnote{The example shows data sets, including \texttt{Prestige}, residing in the \textbf{car} package; these data sets currently reside in the \textbf{carData} package, which is loaded along with the \textbf{car} package when the \textbf{R Commander} starts up.} If you
know the name of a data set in a package then you can enter its name directly;
otherwise double-clicking on the name of a package displays its data sets in
the right list box; and double-clicking on a data set name copies the name to
the data-set entry field in the dialog.\footnote{In general in the \textbf{R
Commander}, when it is necessary to copy an item from a list box to another
location in a dialog, a double-click is required.} Pressing a letter key in
the \emph{Data set} list box will scroll to the next data set whose name
begins with that letter. You can access additional \textbf{R} packages that
are installed in your package library by \emph{Tools }$\longrightarrow
$\emph{\ Load packages}.%


\begin{figure}[ptb]%
\centering
\includegraphics[
height=2.0108in,
width=2.6833in
]%
{fig-6-5.jpg}%
\caption{Reading data from an attached package --- in this case the
\texttt{Prestige} data set from the \textbf{car} package.}%
\label{fig-6-5}%
\end{figure}


\section{Creating Numerical Summaries and Graphs}

Once there is an active data set, you can use the \textbf{R Commander} menus
to produce a variety of numerical summaries and graphs. I will describe just
a few basic examples here. A good GUI should be largely self-explanatory. If
you prefer a more extensive introduction to the \textbf{R Commander}, see
\citet{Fox17}.

In the initial examples below, I assume that the active data set is the
\texttt{Nations} data set, read from a text file in the previous section. If
you typed in the five-observation data set from Moore (2000), or read in the
\texttt{Prestige}\ data set from the \textbf{car} package --- operations that
were also described in the previous section --- then one of these is the
active data set. Recall that you can change the active data set by clicking on
the flat button with the active data set's name near the top left of the
\emph{R Commander} window, choosing from among a list of data sets currently
resident in memory.

Selecting \emph{Statistics }$\longrightarrow$\emph{\ Summaries }%
$\longrightarrow$\emph{\ Active data set} produces the results shown in Figure
\ref{fig-7}. For each numerical variable in the data set (\texttt{TFR},
\texttt{contraception}, \texttt{infant.mortality}, and \texttt{GDP}),
\textbf{R} reports the minimum and maximum values, the first and third
quartiles, the median, and the mean, along with the number of missing values.
For the categorical variable \texttt{region}, I get the number of
observations at each \textquotedblleft level\textquotedblright\ of the factor.
Had the data set included more than ten variables, the \textbf{R Commander}
would have asked me whether I really want to proceed --- potentially
protecting me from producing unwanted voluminous output. This menu item is
unusual in that it directly invokes an \textbf{R} command rather than leading
to a dialog box, as is more typical of \textbf{R Commander} menus.%

\begin{figure}[ptb]%
\centering
\includegraphics[
height=5.6446in,
width=4.8609in
]%
{fig-7.jpg}%
\caption{Getting variable summaries for the active data set.}%
\label{fig-7}%
\end{figure}

\begin{figure}[ptb]%
\centering
\includegraphics[
height=2.352in,
width=3.4255in
]%
{fig-8.jpg}%
\caption{The \emph{Data} tab in the \emph{Numerical Summaries} dialog box.}%
\label{fig-8}%
\end{figure}

For example, selecting \emph{Statistics }$\longrightarrow$\emph{\ Summaries
}$\longrightarrow$\emph{\ Numerical summaries...} brings up the dialog box in
Figure \ref{fig-8}. Only numerical variables appear in the variable list in
this dialog; the factor \texttt{region} is excluded because it is not sensible
to compute numerical summaries like the mean and standard deviation for a
factor. I selected the variable \texttt{infant.mortality} by left-clicking on
it.\footnote{To select a single variable in a variable-list box, simply
left-click on its name. In some contexts, you will have to (or want to) select
more than one variable. In these cases, the usual \textbf{Windows} conventions
apply: Left-clicking on a variable selects it and de-selects any variables
that have previously been selected; \emph{Shift-left-click} extends the
selection; and \emph{Ctrl-left-click} toggles the selection for an individual
variable.} The \emph{Numerical Summaries} dialog box has two tabs: \emph{Data}
and \emph{Statistics}. Click on the \emph{Statistics} tab to select it, as
shown in Figure \ref{fig-8a}. In this case, I'll take all of the default
statistics selections. Clicking \emph{OK}, produces the following output (in
the \emph{Output} pane):
\begin{verbatim}
> numSummary(Nations[,"infant.mortality"], statistics=c("mean", "sd", "IQR",
+   "quantiles"), quantiles=c(0,.25,.5,.75,1))
     mean       sd IQR 0% 25% 50% 75% 100%   n NA
 43.47761 38.75604  54  2  12  30  66  169 201  6
\end{verbatim}%

\begin{figure}[ptb]%
\centering
\includegraphics[
height=2.352in,
width=3.4255in
]%
{fig-8a.jpg}%
\caption{The \emph{Statistics} tab in the \emph{Numerical Summaries} dialog
box.}%
\label{fig-8a}%
\end{figure}

\noindent By default, the \textbf{R} command that is executed prints out the
mean, standard deviation (\texttt{sd}), and interquartile range (\texttt{IQR})
of the variable, along with quantiles (percentiles) corresponding to the
minimum, the first quartile, the median, the third quartile, and the maximum;
\texttt{n} is the number of valid obserations, and \texttt{NA} the number of
missing values.

As is typical of \textbf{R Commander} dialogs, the \emph{Numerical Summaries}
dialog box in Figure \ref{fig-8} includes \emph{Help}, \emph{Reset},
\emph{OK}, \emph{Cancel}, and \emph{Apply} buttons.\footnote{The order of the
buttons varies according to the operating system, and is different, for
example, in \textbf{macOS} than in \textbf{Windows}.} The \emph{Help}
button leads to a help page (which appears in your web browser) either for the
dialog itself or (as here) for an \textbf{R} function that the dialog invokes.
The \emph{Reset} button, which is present in most \textbf{R Commander}
dialogs, resets the dialog to its original state; otherwise, the dialog
retains selections from a previous invocation. Dialog state is also reset when
the active data set changes. As demonstrated, the \emph{OK} button closes the
dialog and generates an \textbf{R} command. The \emph{Apply} button also
generates a command, but then reopens the dialog in its current state,
facilitating the application of several similar operations. If you make an
error in a dialog box --- for example, clicking \emph{OK} without choosing a
variable in the \emph{Numerical Summarie}s dialog --- an error message will
typically appear and the dialog box will reopen.%

\begin{figure}[ptb]%
\centering
\includegraphics[
height=3.3574in,
width=4.0913in
]%
{fig-8-1.jpg}%
\caption{Selecting a grouping variable in the \emph{Groups} dialog box.}%
\label{fig-8-1}%
\end{figure}

\begin{figure}[ptb]%
\centering
\includegraphics[
height=2.352in,
width=3.4255in
]%
{fig-8-2.jpg}%
\caption{The \emph{Numerical Summaries} dialog box after the grouping variable
\texttt{region} has been chosen and with two numeric variables selected.}%
\label{fig-8-2}%
\end{figure}

The \emph{Numerical Summaries} dialog box also makes provision for computing
summaries within groups defined by the levels of a factor. Clicking on the
\emph{Summarize by groups...} button in the \emph{Data} tab brings up the
\emph{Groups} dialog, as shown in Figure \ref{fig-8-1}. Because there is only
one factor in the \texttt{Nations} data set, only the variable \texttt{region}
appears in the variable list, and it is pre-selected; clicking \emph{OK}
changes the \emph{Summarize by groups...} button to \emph{Summarize by region}
(see Figure \ref{fig-8-2}). In this case, I have selected two numerical
variables to summarize, \texttt{GDP} and \texttt{infant.mortality}. Clicking
\emph{OK} produces the following results in the \emph{Output} pane:
\begin{verbatim}
> numSummary(Nations[,c("GDP", "infant.mortality")], groups=Nations$region,
+   statistics=c("mean", "sd", "IQR", "quantiles"), quantiles=c(0,.25,.5,.75,1))

Variable: GDP
              mean        sd      IQR  0%     25%    50%      75%  100%  n NA
Africa    1196.000  2089.614   795.50  36  209.00  389.5  1004.50 11854 54  1
Americas  5398.000  6083.311  5268.50 386 1749.25 2765.5  7017.75 26037 40  1
Asia      4505.051  6277.738  6062.50 122  345.00 1079.0  6407.50 22898 39  2
Europe   13698.909 13165.412 24582.25 271 1643.75 9222.5 26226.00 42416 44  1
Oceania   8732.600 11328.708 16409.25 654 1102.75 2348.5 17512.00 41718 20  5

Variable: infant.mortality
             mean        sd  IQR 0%   25%  50%    75% 100%  n NA
Africa   85.27273 35.188095 50.0  7 61.00 85.0 111.00  169 55  0
Americas 25.60000 17.439713 24.0  6 12.00 21.5  36.00   82 40  1
Asia     45.65854 32.980001 50.0  5 22.00 37.0  72.00  154 41  0
Europe   11.85366  7.122363 10.0  5  6.00  8.0  16.00   32 41  4
Oceania  27.79167 29.622229 26.5  2  9.25 20.0  35.75  135 24  1
\end{verbatim}

\noindent Several other \textbf{R Commander} dialogs allow you to select a
grouping variable in this manner.

Making graphs with the \textbf{R Commander} is also straightforward. For
example, selecting \emph{Graphs }$\longrightarrow$\emph{\ Histogram... }from
the \textbf{R Commander} menus produces the \emph{Histogram} dialog box in
Figure \ref{fig-9}. There are \emph{Data} and \emph{Options} tabs in this
dialog. I'll take all the default options (the \emph{Options} tab isn't
shown), and clicking on \texttt{infant.mortality} followed by \emph{OK}, opens
a \emph{Graphics Device} window with the histogram shown in Figure
\ref{fig-10}. If you make several graphs in a session, then only the most
recent normally appears in the \emph{Graphics Device} window.\footnote{On
\textbf{Windows}, you can recall previous graphs using the \emph{Page Up} and
\emph{Page Down} keys on your keyboard if you first turn on the graph history
feature of the \textbf{Windows R} graphics device, via History
$\longrightarrow$ Recording. In
\textbf{macOS}, the left and right arrows may be used to scroll through graphs. Dynamic three-dimensional graphs, created, for example, by
\emph{Graphs }$\longrightarrow$\emph{\ 3D graph }$\longrightarrow$\ \emph{3D
scatterplot...} appear in a special \emph{RGL device} window.}%

\begin{figure}[ptb]%
\centering
\includegraphics[
height=2.073in,
width=3.4255in
]%
{fig-9.jpg}%
\caption{The \emph{Histogram} dialog. }%
\label{fig-9}%
\end{figure}

\begin{figure}[ptb]%
\centering
\includegraphics[
height=4.4076in,
width=4.1569in
]%
{fig-10.jpg}%
\caption{A graphics window containing the histogram for infant mortality in
the \texttt{Nations} data set.}%
\label{fig-10}%
\end{figure}

\section{Statistical Models}

Several kinds of statistical models can be fit\ in the \textbf{R Commander}
using menu items under \emph{Statistics }$\longrightarrow$\emph{\ Fit models}:
linear models (by both \emph{Linear regression} and \emph{Linear model}),
generalized linear models, multinomial logit models, ordinal regression
models such as the proportional-odds model [the latter two from Venables and
Ripley's \textbf{nnet} and \textbf{MASS} packages,
respectively \citep{VenablesRipley02}], and linear and generalized linear models [using the \textbf{lme4} package \citep{BatesMachlerBolker15}]. Although the resulting dialog boxes
differ in certain details (for example, the generalized linear model dialog
makes provision for selecting a distributional family and corresponding link
function), they share a common general structure, as illustrated in the
\emph{Linear Model} dialog in Figure \ref{fig-10-5}.\footnote{An exception is
the \emph{Linear Regression} dialog in which the response variable and
explanatory variables are simply selected by name from list boxes containing
the numeric variables in the current data set.} Before selecting
\emph{Statistics} $\longrightarrow$\ \emph{Fit models} $\longrightarrow$
\emph{Linear Model}, I made \texttt{Prestige} the active data set by clicking
on the active data set button and selecting \texttt{Prestige} from the
resulting list. Recall that the \texttt{Prestige} data were read from the
\textbf{car} package in Section \ref{sec-data-in-packages}.%

\begin{figure}[ptb]%
\centering
\includegraphics[
height=2.9747in,
width=4.8817in
]%
{fig-10-5.jpg}%
\caption{The \emph{Linear Model} dialog box, with \texttt{Prestige} from the
\textbf{car} package as the active data set.}%
\label{fig-10-5}%
\end{figure}

\begin{itemize}
\item Double-clicking on a variable in the variable-list box copies it to the
model formula --- to the left-hand side of the formula, if it is empty,
otherwise to the right-hand side (with a preceding + sign if the context
requires it). Factors (categorical variables --- here, \texttt{type}) are parenthetically
labelled as such in the variable list.\footnote{Some data frames contain
logical variables (with values \texttt{TRUE} and \texttt{FALSE}) and character
variables, with values that are text strings (such as \texttt{"male"} and
\texttt{"female"}). If such variables are present, the R Commander will treat
them as if they were factors. In most context, this will work properly.
Character data read from plain-text files will automatically be converted to
factors.} Entering a factor into the right-hand side of a statistical model
formula generates dummy-variable regressors.

\item The top row of buttons in the toolbar above the formula can be used to
enter operators and parentheses into the right-hand side of the formula.

\item The bottom row of buttons in the toolbar can be conveniently used to
enter regression-spline and polynomial terms into the model formula, with the
degrees of freedom for splines and the degree of polynomials controlled by the
spin-boxes to the right of the buttons (defaulting to 5 df and degree 2, respectively).

\item You can also type directly into the formula fields, and indeed may have
to do so, for example, to put a term such as \texttt{log(income)} into the
formula, as I've done here. Some information on \textbf{R} model formulas may
be obtained by pressing the \emph{Model formula help} button in the
linear-model dialog.

\item The name of the model, here \texttt{LinearModel.1}, is automatically
generated, but you can substitute any valid \textbf{R} name.

\item You can type an \textbf{R} expression into the box labelled \emph{Subset
expression}; if supplied, this is passed to the \texttt{subset} argument of
the \texttt{lm} function, and is used to fit the model to a subset of the
observations in the data set. One form of subset expression is a logical
expression that evaluates to \texttt{TRUE} or \texttt{FALSE} for each
observation, such as \texttt{type != "prof"} (which would select all
non-professional occupations from the \texttt{Prestige} data set).

\item In version 2.8-0 of the \textbf{R Commander} (or later), there's also a text box into which you can type the names or numbers of cases (rows) to be omitted from the fitted model. (This box isn't shown in Figure~\ref{fig-10-5}.)

\item Optionally selecting a weight variable in the \emph{Weights} drop-down
list produces a weighted-least-squares (WLS) regression.
\end{itemize}

Clicking the \emph{OK} button generates the following command and\ output, and
makes \texttt{LinearModel.1} the active model, with its name displayed in the
\emph{Model} button:
\begin{verbatim}
> LinearModel.1 <- lm(prestige ~ (education + log(income))*type,
+   data=Prestige)

> summary(LinearModel.1)

Call:
lm(formula = prestige ~ (education + log(income)) * type, data = Prestige)

Residuals:
    Min      1Q  Median      3Q     Max
-13.970  -4.124   1.206   3.829  18.059

Coefficients:
                          Estimate Std. Error t value Pr(>|t|)
(Intercept)              -120.0459    20.1576  -5.955 5.07e-08 ***
education                   2.3357     0.9277   2.518  0.01360 *
log(income)                15.9825     2.6059   6.133 2.32e-08 ***
type[T.prof]               85.1601    31.1810   2.731  0.00761 **
type[T.wc]                 30.2412    37.9788   0.796  0.42800
education:type[T.prof]      0.6974     1.2895   0.541  0.58998
education:type[T.wc]        3.6400     1.7589   2.069  0.04140 *
log(income):type[T.prof]   -9.4288     3.7751  -2.498  0.01434 *
log(income):type[T.wc]     -8.1556     4.4029  -1.852  0.06730 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 6.409 on 89 degrees of freedom
  (4 observations deleted due to missingness)
Multiple R-squared:  0.871, Adjusted R-squared:  0.8595
F-statistic: 75.15 on 8 and 89 DF,  p-value: < 2.2e-16
\end{verbatim}

Operations on the active model may be selected from the \emph{Models} menu.
For example, \emph{Models }$\longrightarrow$\emph{\ Hypothesis tests
}$\longrightarrow$\emph{\ Anova table...}, followed by selecting the default
\textquotedblleft Type-II\textquotedblright\ tests, produces the following output:
\begin{verbatim}
> Anova(LinearModel.1, type="II")
Anova Table (Type II tests)

Response: prestige
                 Sum Sq Df F value    Pr(>F)
education        1209.3  1 29.4446 4.912e-07 ***
log(income)      1690.8  1 41.1670 6.589e-09 ***
type              469.1  2  5.7103  0.004642 **
education:type    178.8  2  2.1762  0.119474
log(income):type  290.3  2  3.5344  0.033338 *
Residuals        3655.4 89
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
\end{verbatim}

\section{Odds and Ends}

\subsection{Producing Reports\label{sec-markdown}}

In its default configuration, the \textbf{R Commander} includes an \emph{R
Markdown} tab in the upper pane, which accumulates the commands generated
during the session in an\textbf{\ R Markdown}
document.\footnote{The\textbf{\ R Commander} can also optionally create a
\textbf{knitr} \textbf{LaTeX} document \citep{Xie16} and compile
it into a PDF file. This option requires a \textbf{LaTeX} installation, and is
activated by setting the \textbf{Rcmdr} option \texttt{use.knitr} to
\texttt{TRUE}. see \emph{Help} $\longrightarrow$ \emph{Commander help} and
\emph{Tools} $\longrightarrow$ \emph{Options}.} Figure \ref{fig-11} shows
the\emph{\ R Markdown} tab for the current session, which I've scrolled to
the top of the generated document. As its name implies, \textbf{R Markdown} is
a simple markup language, which includes blocks of \textbf{R} commands, and
can be used to generate HTML (i.e., web) pages or other types of documents. For more information about
\textbf{R Markdown}, select \emph{Help} $\longrightarrow$\ \emph{Using R
Markdown} from the \textbf{R Commander} menus.\footnote{This and some other
items in the \emph{Help} menu require an active internet connection.}%

\begin{figure}[ptb]%
\centering
\includegraphics[
height=2.6907in,
width=4.9373in
]%
{fig-11.jpg}%
\caption{The \emph{R Markdown} tab, with \emph{Generate report} button.}%
\label{fig-11}%
\end{figure}


Each set of commands generated by the \textbf{R Commander} produces a block of
\textbf{R} commands in the \textbf{R Markdown} document.\footnote{Commands
that require direct user interaction, such as interactive point identification
in a graph, are suppressed in the \textbf{R Markdown} document. As well,
commands that generate errors are removed from the document.} These blocks are
delimited by \verb|```{r}| at the start of each block and by \verb|```|
(three back-ticks) at the end of the block. Even if you are unfamiliar with
\textbf{R} commands, you can see the relationship between commands and
resulting output in the \emph{Output} pane.

The \emph{R Markdown} tab is editable, and so you can modify and add to the
text in the tab. It is generally safe to type whatever explanatory text you
wish \emph{between} blocks of \textbf{R} code (see below). In general,
however, unless you know what you're doing, you should not modify \textbf{R}
code blocks in the \textbf{R Markdown} document or add your own code blocks.
You can, however, remove entire blocks of code, as long as subsequent blocks
don't depend on them \ --- and you will likely want to remove command blocks
that produce unwanted output. Command blocks that produce errors are removed
automatically. You can remove the most recent command block by selecting
\emph{Remove last Markdown Command Block} from the \emph{Edit} menu, or by
right-clicking in the \emph{R Markdown} tab and selecting \emph{Remove last
Markdown Command Block} from the context menu. The first code block (which
begins \verb|```{r echo=FALSE}|) sets some options for the software from the \textbf{knitr} package (Xie,
2013) that is used to process the \textbf{R Markdown} text, and this block
should not normally be modified.

With some lines elided (indicated by \texttt{. . .}), here is the \textbf{R
Markdown} document produced for the current session:
\begin{verbatim}
---
title: "Replace with Main Title"
author: "John Fox"
date: "`r Sys.Date()`"  # Uses current date
---


```{r echo=FALSE, message=FALSE}
# include this code chunk as-is to set options
knitr::opts_chunk$set(comment=NA, prompt=TRUE)
library(Rcmdr)
library(car)
library(RcmdrMisc)
```


```{r echo=FALSE}
# include this code chunk as-is to enable 3D graphs
library(rgl)
knitr::knit_hooks$set(webgl = hook_webgl)
```


```{r}
Nations <- read.table("C:/R/R-3.3.2/library/Rcmdr/etc/Nations.txt",
  header=TRUE, sep="", na.strings="NA", dec=".", strip.white=TRUE)
```

. . .


```{r}
data(Prestige, package="car")
```

. . .

Let us regress occupational prestige on the education and income levels of the occupations,
transforming income to linearize its relationship to prestige:

### Linear Model: LinearModel.1: prestige ~ (education + log(income))*type
```{r}
LinearModel.1 <- lm(prestige ~ (education + log(income))*type,
  data=Prestige)
summary(LinearModel.1)
```

### Analysis of Variance: LinearModel.1
```{r}
Anova(LinearModel.1, type="II")
```

\end{verbatim}

\noindent It is probably unnecessary to explain that you would normally
replace \textquotedblleft\texttt{Replace\ with\ Main\ Title}%
\textquotedblright\ with the title of the report that you want to create.
Perhaps less obviously, you can type arbitrary explanatory text before the
first command block, \emph{in between} \textbf{R} code blocks --- that is,
between the terminating \verb|```| of one block and starting \verb|```{r}|
of the next --- and after the last command block. You can take advantage of
the simple markup provided by \textbf{R Markdown}; for example, text enclosed
in asterisks (e.g., \texttt{*this is important*}) will be set in
\textit{italic} type. To illustrate, I added the text \textquotedblleft%
\texttt{Let us regress occupational prestige ...} \textquotedblright%
\ immediately before the \textbf{R} command block performing the regression.

The \textbf{R Markdown} document also includes automatically generated section headings for some \textbf{R} command blocks. These are preceded by three hashmarks (\texttt{\#\#\#}), which indicate a level-3 heading. When the \textbf{R Markdown} documented is converted into a report (see immediately below), the headers appear not only in the text but in an automatically generated index. You can edit these headings to customize them, and you can also add your own headings, using, for example, \texttt{\#} for a level-1 heading and \texttt{\#\#} for a level-2 heading.

Once you have finished editing the \textbf{R Markdown} document, you can
generate a report from it in the form of an HTML document (web page), \textbf{Word} document,
rich text file,
or PDF file by pressing the \emph{Generate report}
button below the \emph{R Markdown} tab.\footnote{To generate \textbf{Word} or rich text file documents you must
install \textbf{Pandoc}; to generate PDF files, you'll additionally
need \LaTeX. To install this optional auxiliary software, use the \emph{Tools} menu.}
An HTML report should open in your web browser, and a PDF report in your PDF viewer.
\textbf{Word} and rich text files must be opened manually, but can easily be edited further.
The \textbf{R Markdown} document can be saved via the \emph{File} menu.

You can also, and more conveniently, open a separate and larger editor window to edit the \textbf{R
Markdown} document (see Figure \ref{fig-12}): Select \emph{Edit R Markdown
document} from the \textbf{R Commander} \emph{Edit} menu; right-click in the
\emph{R Markdown} tab and select \emph{Edit R Markdown document} from the
context menu; or press the key-combination \emph{Control-E} when the cursor is
in the \emph{R Markdown} tab. The editor supports the usual \emph{Edit}-menu
and right-click context-menu commands, and also allows you to compile the
\textbf{R Markdown} document into an HTML report. Clicking the \emph{OK} button
in the editor saves your edits to the \emph{R Markdown} tab, and clicking
\emph{Cancel} discards your edits. Below the menu in the editor, there is a
largely self-explanatory toolbar with various buttons; if you hover the mouse
over a button, a \textquotedblleft tool-tip\textquotedblright\ will display.

You can open the \textbf{R Markdown} editor window at the beginning of a session
and leave it open while you work. Commands generated by the \textbf{R Commander}
will be entered both into the \emph{R Markdown} tab and the editor, and you'll be
able to write text in the editor as you go. See the editor help for more information.

\begin{figure}[ptb]%
\centering
\includegraphics[
height=5.3873in,
width=5.1374in
]%
{fig-12.jpg}%
\caption{The \textbf{R Markdown} document editor. (Note: This image of the editor was created in an earlier version of the \textbf{R Commander}, which didn't automatically generate level-3 section headings for commands.)}%
\label{fig-12}%
\end{figure}


\subsection{Saving and Printing Output}

You can also save text output directly from the \emph{File} menu in the
\textbf{R Commander;} likewise you can save or print a graph from the
\emph{File} menu in an \textbf{R} \emph{Graphics Device} window. If you prefer
not to use the \emph{R Markdown} tab, you can collect the text output and
graphs that you want to keep in a word-processor document. In this manner, you
can intersperse \textbf{R} output with your typed notes and explanations. This
procedure, however, has the disadvantage that it is not directly reproducible,
while an \textbf{R Markdown} document can subsequently be executed to
reproduce your analysis, possibly with modifications.

Open a word processor such as \textbf{Word},\textbf{\ OpenOffice Writer}, or
even \textbf{Windows} \textbf{WordPad}. To copy text from the \emph{Output}
pane, block the text with the mouse, select \emph{Copy} from the \emph{Edit}
menu (or press the key combination \emph{Ctrl-c}, or right-click in the pane
and select \emph{Copy} from the context menu), and then paste the text into
the word-processor document via \emph{Edit }$\longrightarrow$\emph{\ Paste}
(or \emph{Ctrl-v }or right-click \emph{Paste}), as you would for any
\textbf{Windows} application. One point worth mentioning is that you should
use a monospaced (\textquotedblleft\texttt{typewriter}\textquotedblright)
font, such as \emph{Courier New}, for text output from \textbf{R}; otherwise
the output will not line up neatly.

Likewise, to copy a graph, select \emph{File }$\longrightarrow$\emph{\ Copy to
the clipboard }$\longrightarrow$\emph{\ as a Metafile} from the \textbf{R}
\emph{Graphics Device} menus; then paste the graph into the word-processor
document via \emph{Edit }$\longrightarrow$\emph{\ Paste} (or \emph{Ctrl-v} or
right-click \emph{Paste}). Alternatively, you can use \emph{Ctrl-w} to copy
the graph from the \textbf{R} \emph{Graphics Device}, or right-click on the
graph to bring up a context menu, from which you can select \emph{Copy as
metafile}.\footnote{As you will see when you examine these menus, you can save
graphs in a variety of formats, and to files as well as to the clipboard. The
procedure suggested here is straightforward, however, and generally results in
high-quality graphs. Once again, this description applies to \textbf{Windows}
systems.} At the end of your \textbf{R} session, you can save or print the
document that you have created, providing an annotated record of your work.

Alternative routes to saving text and graphical output may be found
respectively under the \textbf{R Commander }\emph{File} and \emph{Graphs
}$\longrightarrow$\emph{\ Save graph to file} menus. Saving the \textbf{R
Commander} \emph{Script} tab, via \emph{File }$\longrightarrow$\emph{\ Save
script}, allows you to reproduce your work on a future occasion.

\subsection{Entering Commands in the Script Tab}

The \emph{R Script} tab provides a simple facility for editing, entering, and
executing commands. Commands generated by the \textbf{R Commander} appear in
the \emph{Script} tab, and you can type and edit commands in the tab more or
less as in any editor. The \textbf{R Commander} does not provide a true
\textquotedblleft console\textquotedblright\ for \textbf{R}, however, and the
\emph{Script} tab has some limitations. For example, all lines of a multiline
command must be submitted simultaneously for execution. For serious \textbf{R}
programming, it is preferable to use the script editors provided by the
\textbf{Windows} and \textbf{macOS} versions of \textbf{R}, or --- even
better --- a programming editor or interactive development environment, such
as \textbf{RStudio} <\href{https://www.rstudio.com/}{www.rstudio.com}>.\footnote{
The \textbf{R Commander} will run under \textbf{RStudio}, in which
case by default \textbf{R Commander} output and messages are directed to the
\textbf{R} console within \textbf{RStudio}.}

\subsection{Using R Commander Plug-ins\label{sec-plugins}}

\textbf{R Commander} plug-ins are \textbf{R} packages that add to the
capabilities of the \textbf{R Commander}. Many such plug-ins are currently
available on CRAN, and may be downloaded and installed in the normal manner.
Plug-ins typically add menus or menu items and associated dialog boxes to the
\textbf{R Commander}. They may also modify or remove existing menu items or
dialogs. A properly programmed \textbf{R Commander} plug-in can be loaded
either directly, in which case the \textbf{R Commander }loads along with the
plug-in, or from the \textbf{R Commander} via \emph{Tools} $\longrightarrow$
\emph{Load Rcmdr plug-in(s)...} . In the latter event, the \textbf{R
Commander} will restart to activate the plug-in. It is possible to use several
plug-ins simultaneously, but plug-ins may also conflict with each other. For
example, one plug-in may remove a menu to which another plug-in tries to add a
menu item.

\subsection{Terminating the R Session}

There are several ways to terminate your session. For example, you can select
\emph{File }$\longrightarrow$\emph{\ Exit }$\longrightarrow$\emph{\ From
Commander and R} from the \textbf{R Commander }menus. You will be asked to
confirm, and then asked whether you want to save the contents of the \emph{R
Script}, \emph{Output}, and \emph{R Markdow}n windows. Likewise, you can
select \emph{File }$\longrightarrow$\emph{\ Exit} from the \emph{R Console};
in this case, you will be asked whether you want to save the \textbf{R}
workspace (i.e., the data that \textbf{R} keeps in memory); you would normally
answer \emph{No}: Saving the \textbf{R} workspace will likely create problems in subsequent sessions.

\bibliography{Rcmdr-Manual}



\end{document}