-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtutorial-installing-understanding-rr-studio.html
801 lines (760 loc) · 73.9 KB
/
tutorial-installing-understanding-rr-studio.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
<!DOCTYPE html>
<html lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title> 1 Tutorial: Installing & Understanding R/R Studio | R for Conditional Process Analysis</title>
<meta name="description" content="Using Conditional Process Analysis to evaluate communication theories - B.A. Seminar at IKMZ, FS 2022" />
<meta name="generator" content="bookdown 0.24 and GitBook 2.6.7" />
<meta property="og:title" content=" 1 Tutorial: Installing & Understanding R/R Studio | R for Conditional Process Analysis" />
<meta property="og:type" content="book" />
<meta property="og:description" content="Using Conditional Process Analysis to evaluate communication theories - B.A. Seminar at IKMZ, FS 2022" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content=" 1 Tutorial: Installing & Understanding R/R Studio | R for Conditional Process Analysis" />
<meta name="twitter:description" content="Using Conditional Process Analysis to evaluate communication theories - B.A. Seminar at IKMZ, FS 2022" />
<meta name="author" content="Lara Kobilke, IKMZ, University of Zurich" />
<meta name="date" content="2022-05-04" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="prev" href="index.html"/>
<link rel="next" href="tutorial-workflow-in-r.html"/>
<script src="libs/header-attrs-2.11/header-attrs.js"></script>
<script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6/dist/fuse.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-clipboard.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.0.1/anchor-sections.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.0.1/anchor-sections.js"></script>
<script src="libs/htmlwidgets-1.5.4/htmlwidgets.js"></script>
<script src="libs/viz-1.8.2/viz.js"></script>
<link href="libs/DiagrammeR-styles-0.2/styles.css" rel="stylesheet" />
<script src="libs/grViz-binding-1.0.9/grViz.js"></script>
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
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;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li><a href="./">CPA Seminar</a></li>
<li class="divider"></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>General information on the course</a>
<ul>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#how-to-use-this-tutorial"><i class="fa fa-check"></i>How to use this tutorial</a></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#what-can-i-do-if-questions-arise"><i class="fa fa-check"></i>What can I do if questions arise?</a></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#what-can-i-do-if-i-have-problems-with-my-r-code"><i class="fa fa-check"></i>What can I do if I have problems with my R code?</a></li>
</ul></li>
<li class="chapter" data-level="1" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html"><i class="fa fa-check"></i><b>1</b> Tutorial: Installing & Understanding R/R Studio</a>
<ul>
<li class="chapter" data-level="1.1" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#installing-r"><i class="fa fa-check"></i><b>1.1</b> Installing R</a></li>
<li class="chapter" data-level="1.2" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#installing-r-studio"><i class="fa fa-check"></i><b>1.2</b> Installing R Studio</a></li>
<li class="chapter" data-level="1.3" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#updating-r-and-r-studio"><i class="fa fa-check"></i><b>1.3</b> Updating R and R Studio</a>
<ul>
<li class="chapter" data-level="1.3.1" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#on-windows"><i class="fa fa-check"></i><b>1.3.1</b> On Windows</a></li>
<li class="chapter" data-level="1.3.2" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#on-mac"><i class="fa fa-check"></i><b>1.3.2</b> On MAC</a></li>
</ul></li>
<li class="chapter" data-level="1.4" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#how-does-r-work"><i class="fa fa-check"></i><b>1.4</b> How does R work?</a></li>
<li class="chapter" data-level="1.5" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#how-does-r-studio-work"><i class="fa fa-check"></i><b>1.5</b> How does R Studio work?</a>
<ul>
<li class="chapter" data-level="1.5.1" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#source-writing-your-own-code"><i class="fa fa-check"></i><b>1.5.1</b> Source: Writing your own code</a></li>
<li class="chapter" data-level="1.5.2" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#console-printing-results"><i class="fa fa-check"></i><b>1.5.2</b> Console: Printing results</a></li>
<li class="chapter" data-level="1.5.3" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#environment-overview-of-objects"><i class="fa fa-check"></i><b>1.5.3</b> Environment: Overview of objects</a></li>
<li class="chapter" data-level="1.5.4" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#plotshelppackages-do-everything-else"><i class="fa fa-check"></i><b>1.5.4</b> Plots/Help/Packages: Do everything else</a></li>
</ul></li>
<li class="chapter" data-level="1.6" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#take-aways"><i class="fa fa-check"></i><b>1.6</b> Take-Aways</a></li>
<li class="chapter" data-level="1.7" data-path="tutorial-installing-understanding-rr-studio.html"><a href="tutorial-installing-understanding-rr-studio.html#additional-tutorials"><i class="fa fa-check"></i><b>1.7</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html"><i class="fa fa-check"></i><b>2</b> Tutorial: Workflow in R</a>
<ul>
<li class="chapter" data-level="2.1" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#defining-your-working-directory"><i class="fa fa-check"></i><b>2.1</b> Defining your working directory</a></li>
<li class="chapter" data-level="2.2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#packages"><i class="fa fa-check"></i><b>2.2</b> Packages</a>
<ul>
<li class="chapter" data-level="2.2.1" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#installing-packages"><i class="fa fa-check"></i><b>2.2.1</b> Installing packages</a></li>
<li class="chapter" data-level="2.2.2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#activating-packages"><i class="fa fa-check"></i><b>2.2.2</b> Activating packages</a></li>
<li class="chapter" data-level="2.2.3" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#getting-information-about-packages"><i class="fa fa-check"></i><b>2.2.3</b> Getting information about packages</a></li>
</ul></li>
<li class="chapter" data-level="2.3" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#help"><i class="fa fa-check"></i><b>2.3</b> Help?!</a>
<ul>
<li class="chapter" data-level="2.3.1" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#finding-information-about-packages"><i class="fa fa-check"></i><b>2.3.1</b> Finding information about packages</a></li>
<li class="chapter" data-level="2.3.2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#finding-information-about-functions"><i class="fa fa-check"></i><b>2.3.2</b> Finding information about functions</a></li>
<li class="chapter" data-level="2.3.3" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#searching-for-help-online"><i class="fa fa-check"></i><b>2.3.3</b> Searching for help online</a></li>
<li class="chapter" data-level="2.3.4" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#interrupting-r"><i class="fa fa-check"></i><b>2.3.4</b> Interrupting R</a></li>
</ul></li>
<li class="chapter" data-level="2.4" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#saving-loading-cleaning-coderesults"><i class="fa fa-check"></i><b>2.4</b> Saving, loading & cleaning code/results</a>
<ul>
<li class="chapter" data-level="2.4.1" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#saving-your-code"><i class="fa fa-check"></i><b>2.4.1</b> Saving your code</a></li>
<li class="chapter" data-level="2.4.2" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#saving-your-results"><i class="fa fa-check"></i><b>2.4.2</b> Saving your results</a></li>
<li class="chapter" data-level="2.4.3" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#loading-working-spaces"><i class="fa fa-check"></i><b>2.4.3</b> Loading working spaces</a></li>
<li class="chapter" data-level="2.4.4" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#clean-your-working-space"><i class="fa fa-check"></i><b>2.4.4</b> Clean your working space</a></li>
<li class="chapter" data-level="2.4.5" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#take-aways-1"><i class="fa fa-check"></i><b>2.4.5</b> Take Aways</a></li>
</ul></li>
<li class="chapter" data-level="2.5" data-path="tutorial-workflow-in-r.html"><a href="tutorial-workflow-in-r.html#additional-tutorials-1"><i class="fa fa-check"></i><b>2.5</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="3" data-path="tutorial-using-r-as-a-calculator.html"><a href="tutorial-using-r-as-a-calculator.html"><i class="fa fa-check"></i><b>3</b> Tutorial: Using R as a calculator</a>
<ul>
<li class="chapter" data-level="3.1" data-path="tutorial-using-r-as-a-calculator.html"><a href="tutorial-using-r-as-a-calculator.html#using-variables-for-calculation"><i class="fa fa-check"></i><b>3.1</b> Using variables for calculation</a></li>
<li class="chapter" data-level="3.2" data-path="tutorial-using-r-as-a-calculator.html"><a href="tutorial-using-r-as-a-calculator.html#using-vectors-for-calculation"><i class="fa fa-check"></i><b>3.2</b> Using vectors for calculation</a></li>
<li class="chapter" data-level="3.3" data-path="tutorial-using-r-as-a-calculator.html"><a href="tutorial-using-r-as-a-calculator.html#take-aways-2"><i class="fa fa-check"></i><b>3.3</b> Take-Aways</a></li>
</ul></li>
<li class="chapter" data-level="4" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html"><i class="fa fa-check"></i><b>4</b> Tutorial: Objects & structures in R</a>
<ul>
<li class="chapter" data-level="4.1" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#types-of-data"><i class="fa fa-check"></i><b>4.1</b> Types of data</a>
<ul>
<li class="chapter" data-level="4.1.1" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#accessing-variables-in-data-sets"><i class="fa fa-check"></i><b>4.1.1</b> Accessing variables in data sets</a></li>
<li class="chapter" data-level="4.1.2" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#numbers"><i class="fa fa-check"></i><b>4.1.2</b> Numbers</a></li>
<li class="chapter" data-level="4.1.3" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#text"><i class="fa fa-check"></i><b>4.1.3</b> Text</a></li>
<li class="chapter" data-level="4.1.4" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#factors"><i class="fa fa-check"></i><b>4.1.4</b> Factors</a></li>
<li class="chapter" data-level="4.1.5" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#dates"><i class="fa fa-check"></i><b>4.1.5</b> Dates</a></li>
<li class="chapter" data-level="4.1.6" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#missing-datanas"><i class="fa fa-check"></i><b>4.1.6</b> Missing data/NAs</a></li>
<li class="chapter" data-level="4.1.7" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#logicalother-operators"><i class="fa fa-check"></i><b>4.1.7</b> Logical/other operators</a></li>
</ul></li>
<li class="chapter" data-level="4.2" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#types-of-objects"><i class="fa fa-check"></i><b>4.2</b> Types of objects</a>
<ul>
<li class="chapter" data-level="4.2.1" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#scalars"><i class="fa fa-check"></i><b>4.2.1</b> Scalars</a></li>
<li class="chapter" data-level="4.2.2" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#vectors"><i class="fa fa-check"></i><b>4.2.2</b> Vectors</a></li>
<li class="chapter" data-level="4.2.3" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#data-frames-matrices"><i class="fa fa-check"></i><b>4.2.3</b> Data frames & matrices</a></li>
<li class="chapter" data-level="4.2.4" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#lists"><i class="fa fa-check"></i><b>4.2.4</b> Lists</a></li>
<li class="chapter" data-level="4.2.5" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#other-types-of-objects"><i class="fa fa-check"></i><b>4.2.5</b> Other types of objects</a></li>
</ul></li>
<li class="chapter" data-level="4.3" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#take-aways-3"><i class="fa fa-check"></i><b>4.3</b> Take Aways</a></li>
<li class="chapter" data-level="4.4" data-path="tutorial-objects-structures-in-r.html"><a href="tutorial-objects-structures-in-r.html#additional-tutorials-2"><i class="fa fa-check"></i><b>4.4</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="5" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html"><i class="fa fa-check"></i><b>5</b> Tutorial: Reading data in/out</a>
<ul>
<li class="chapter" data-level="5.1" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#getting-data-into-r"><i class="fa fa-check"></i><b>5.1</b> Getting data into R</a></li>
<li class="chapter" data-level="5.2" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#getting-data-out-of-r"><i class="fa fa-check"></i><b>5.2</b> Getting data out of R</a></li>
<li class="chapter" data-level="5.3" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#other-packages-for-getting-data-intoout-of-r"><i class="fa fa-check"></i><b>5.3</b> Other packages for getting data into/out of R</a></li>
<li class="chapter" data-level="5.4" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#take-aways-4"><i class="fa fa-check"></i><b>5.4</b> Take Aways</a></li>
<li class="chapter" data-level="5.5" data-path="tutorial-reading-data-inout.html"><a href="tutorial-reading-data-inout.html#additional-tutorials-3"><i class="fa fa-check"></i><b>5.5</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="6" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html"><i class="fa fa-check"></i><b>6</b> Exercise 1: Test your knowledge</a>
<ul>
<li class="chapter" data-level="6.1" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-1"><i class="fa fa-check"></i><b>6.1</b> Task 1</a></li>
<li class="chapter" data-level="6.2" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-2"><i class="fa fa-check"></i><b>6.2</b> Task 2</a></li>
<li class="chapter" data-level="6.3" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-3"><i class="fa fa-check"></i><b>6.3</b> Task 3</a></li>
<li class="chapter" data-level="6.4" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-4"><i class="fa fa-check"></i><b>6.4</b> Task 4</a></li>
<li class="chapter" data-level="6.5" data-path="exercise-1-test-your-knowledge.html"><a href="exercise-1-test-your-knowledge.html#task-5"><i class="fa fa-check"></i><b>6.5</b> Task 5</a></li>
</ul></li>
<li class="chapter" data-level="7" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html"><i class="fa fa-check"></i><b>7</b> Tutorial: Data management with tidyverse</a>
<ul>
<li class="chapter" data-level="7.1" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#why-not-stick-with-base-r"><i class="fa fa-check"></i><b>7.1</b> Why not stick with Base R?</a></li>
<li class="chapter" data-level="7.2" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#tidyverse-packages"><i class="fa fa-check"></i><b>7.2</b> Tidyverse packages</a></li>
<li class="chapter" data-level="7.3" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#tidy-data"><i class="fa fa-check"></i><b>7.3</b> Tidy data</a></li>
<li class="chapter" data-level="7.4" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#the-pipe-operator"><i class="fa fa-check"></i><b>7.4</b> The pipe operator</a></li>
<li class="chapter" data-level="7.5" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#data-transformation-with-dplyr"><i class="fa fa-check"></i><b>7.5</b> Data transformation with dplyr</a>
<ul>
<li class="chapter" data-level="7.5.1" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#select"><i class="fa fa-check"></i><b>7.5.1</b> select()</a></li>
<li class="chapter" data-level="7.5.2" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#filter"><i class="fa fa-check"></i><b>7.5.2</b> filter()</a></li>
<li class="chapter" data-level="7.5.3" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#arrange"><i class="fa fa-check"></i><b>7.5.3</b> arrange()</a></li>
<li class="chapter" data-level="7.5.4" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#mutate"><i class="fa fa-check"></i><b>7.5.4</b> mutate()</a></li>
<li class="chapter" data-level="7.5.5" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#simmarize-group_by"><i class="fa fa-check"></i><b>7.5.5</b> simmarize() [+ group_by()]</a></li>
<li class="chapter" data-level="7.5.6" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#chaining-functions-in-a-pipe"><i class="fa fa-check"></i><b>7.5.6</b> Chaining functions in a pipe</a></li>
</ul></li>
<li class="chapter" data-level="7.6" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#take-aways-5"><i class="fa fa-check"></i><b>7.6</b> Take-Aways</a></li>
<li class="chapter" data-level="7.7" data-path="tutorial-data-management-with-tidyverse.html"><a href="tutorial-data-management-with-tidyverse.html#additional-tutorials-4"><i class="fa fa-check"></i><b>7.7</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="8" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html"><i class="fa fa-check"></i><b>8</b> Exercise 2: Test your knowledge</a>
<ul>
<li class="chapter" data-level="8.1" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-1-1"><i class="fa fa-check"></i><b>8.1</b> Task 1</a></li>
<li class="chapter" data-level="8.2" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-2-1"><i class="fa fa-check"></i><b>8.2</b> Task 2</a></li>
<li class="chapter" data-level="8.3" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-3-1"><i class="fa fa-check"></i><b>8.3</b> Task 3</a></li>
<li class="chapter" data-level="8.4" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-4-1"><i class="fa fa-check"></i><b>8.4</b> Task 4</a></li>
<li class="chapter" data-level="8.5" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-5-1"><i class="fa fa-check"></i><b>8.5</b> Task 5</a></li>
<li class="chapter" data-level="8.6" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-6"><i class="fa fa-check"></i><b>8.6</b> Task 6</a></li>
<li class="chapter" data-level="8.7" data-path="exercise-2-test-your-knowledge.html"><a href="exercise-2-test-your-knowledge.html#task-7"><i class="fa fa-check"></i><b>8.7</b> Task 7</a></li>
</ul></li>
<li class="chapter" data-level="9" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html"><i class="fa fa-check"></i><b>9</b> Tutorial: Data visualization with ggplot</a>
<ul>
<li class="chapter" data-level="9.1" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#why-not-stick-with-base-r-1"><i class="fa fa-check"></i><b>9.1</b> Why not stick with Base R?</a></li>
<li class="chapter" data-level="9.2" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#components-of-a-ggplot-graph"><i class="fa fa-check"></i><b>9.2</b> Components of a ggplot graph</a></li>
<li class="chapter" data-level="9.3" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#installing-activating-ggplot"><i class="fa fa-check"></i><b>9.3</b> Installing & activating ggplot</a></li>
<li class="chapter" data-level="9.4" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#building-your-first-plot"><i class="fa fa-check"></i><b>9.4</b> Building your first plot</a>
<ul>
<li class="chapter" data-level="9.4.1" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#data"><i class="fa fa-check"></i><b>9.4.1</b> Data</a></li>
<li class="chapter" data-level="9.4.2" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#aesthetics"><i class="fa fa-check"></i><b>9.4.2</b> Aesthetics</a></li>
<li class="chapter" data-level="9.4.3" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#geometrics"><i class="fa fa-check"></i><b>9.4.3</b> Geometrics</a></li>
<li class="chapter" data-level="9.4.4" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#scales"><i class="fa fa-check"></i><b>9.4.4</b> Scales</a></li>
<li class="chapter" data-level="9.4.5" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#themes"><i class="fa fa-check"></i><b>9.4.5</b> Themes</a></li>
<li class="chapter" data-level="9.4.6" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#labs"><i class="fa fa-check"></i><b>9.4.6</b> Labs</a></li>
<li class="chapter" data-level="9.4.7" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#facets"><i class="fa fa-check"></i><b>9.4.7</b> Facets</a></li>
<li class="chapter" data-level="9.4.8" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#saving-graphs"><i class="fa fa-check"></i><b>9.4.8</b> Saving graphs</a></li>
</ul></li>
<li class="chapter" data-level="9.5" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#other-common-plot-types"><i class="fa fa-check"></i><b>9.5</b> Other common plot types</a>
<ul>
<li class="chapter" data-level="9.5.1" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#bar-plots"><i class="fa fa-check"></i><b>9.5.1</b> bar plots</a></li>
<li class="chapter" data-level="9.5.2" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#box-plots"><i class="fa fa-check"></i><b>9.5.2</b> box plots</a></li>
</ul></li>
<li class="chapter" data-level="9.6" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#take-aways-6"><i class="fa fa-check"></i><b>9.6</b> Take Aways</a></li>
<li class="chapter" data-level="9.7" data-path="tutorial-data-visualization-with-ggplot.html"><a href="tutorial-data-visualization-with-ggplot.html#additional-tutorials-5"><i class="fa fa-check"></i><b>9.7</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="10" data-path="exercise-3-test-your-knowledge.html"><a href="exercise-3-test-your-knowledge.html"><i class="fa fa-check"></i><b>10</b> Exercise 3: Test your knowledge</a>
<ul>
<li class="chapter" data-level="10.1" data-path="exercise-3-test-your-knowledge.html"><a href="exercise-3-test-your-knowledge.html#task-1-2"><i class="fa fa-check"></i><b>10.1</b> Task 1</a></li>
<li class="chapter" data-level="10.2" data-path="exercise-3-test-your-knowledge.html"><a href="exercise-3-test-your-knowledge.html#task-2-2"><i class="fa fa-check"></i><b>10.2</b> Task 2</a></li>
<li class="chapter" data-level="10.3" data-path="exercise-3-test-your-knowledge.html"><a href="exercise-3-test-your-knowledge.html#task-3-2"><i class="fa fa-check"></i><b>10.3</b> Task 3</a></li>
</ul></li>
<li class="chapter" data-level="11" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html"><i class="fa fa-check"></i><b>11</b> Tutorial: Linear regression</a>
<ul>
<li class="chapter" data-level="11.1" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#knowing-your-data"><i class="fa fa-check"></i><b>11.1</b> Knowing your data</a></li>
<li class="chapter" data-level="11.2" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#visual-inspection-of-linear-trends"><i class="fa fa-check"></i><b>11.2</b> Visual inspection of linear trends</a></li>
<li class="chapter" data-level="11.3" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#pearsons-r"><i class="fa fa-check"></i><b>11.3</b> Pearson´s r</a></li>
<li class="chapter" data-level="11.4" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#ols-regression"><i class="fa fa-check"></i><b>11.4</b> OLS regression</a></li>
<li class="chapter" data-level="11.5" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#standardizing-coefficients"><i class="fa fa-check"></i><b>11.5</b> Standardizing coefficients</a></li>
<li class="chapter" data-level="11.6" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#multiple-regression"><i class="fa fa-check"></i><b>11.6</b> Multiple regression</a></li>
<li class="chapter" data-level="11.7" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#standardized-multiple-regression"><i class="fa fa-check"></i><b>11.7</b> Standardized multiple regression</a></li>
<li class="chapter" data-level="11.8" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#take-aways-7"><i class="fa fa-check"></i><b>11.8</b> Take Aways</a></li>
<li class="chapter" data-level="11.9" data-path="tutorial-linear-regression.html"><a href="tutorial-linear-regression.html#additional-tutorials-6"><i class="fa fa-check"></i><b>11.9</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="12" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html"><i class="fa fa-check"></i><b>12</b> Exercise 4: Test your knowledge</a>
<ul>
<li class="chapter" data-level="12.1" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-1-3"><i class="fa fa-check"></i><b>12.1</b> Task 1</a></li>
<li class="chapter" data-level="12.2" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-2-3"><i class="fa fa-check"></i><b>12.2</b> Task 2</a></li>
<li class="chapter" data-level="12.3" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-3-3"><i class="fa fa-check"></i><b>12.3</b> Task 3</a></li>
<li class="chapter" data-level="12.4" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-4-2"><i class="fa fa-check"></i><b>12.4</b> Task 4</a></li>
<li class="chapter" data-level="12.5" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-5-2"><i class="fa fa-check"></i><b>12.5</b> Task 5</a></li>
<li class="chapter" data-level="12.6" data-path="exercise-4-test-your-knowledge.html"><a href="exercise-4-test-your-knowledge.html#task-6-1"><i class="fa fa-check"></i><b>12.6</b> Task 6</a></li>
</ul></li>
<li class="chapter" data-level="13" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html"><i class="fa fa-check"></i><b>13</b> Tutorial: Mediation analysis</a>
<ul>
<li class="chapter" data-level="13.1" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#introduction-to-mediation"><i class="fa fa-check"></i><b>13.1</b> Introduction to mediation</a></li>
<li class="chapter" data-level="13.2" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#difference-between-mediation-and-moderation"><i class="fa fa-check"></i><b>13.2</b> Difference between mediation and moderation</a></li>
<li class="chapter" data-level="13.3" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#two-step-process-of-mediation"><i class="fa fa-check"></i><b>13.3</b> Two-step process of mediation</a></li>
<li class="chapter" data-level="13.4" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#statistical-representation-and-equations"><i class="fa fa-check"></i><b>13.4</b> Statistical representation and equations</a>
<ul>
<li class="chapter" data-level="13.4.1" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#direct-effect-c"><i class="fa fa-check"></i><b>13.4.1</b> Direct effect <em>c′</em></a></li>
<li class="chapter" data-level="13.4.2" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#indirect-effect-ab"><i class="fa fa-check"></i><b>13.4.2</b> Indirect effect <em>ab</em></a></li>
<li class="chapter" data-level="13.4.3" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#total-effect"><i class="fa fa-check"></i><b>13.4.3</b> Total effect</a></li>
</ul></li>
<li class="chapter" data-level="13.5" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#example"><i class="fa fa-check"></i><b>13.5</b> Example</a>
<ul>
<li class="chapter" data-level="13.5.1" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#knowing-your-data-1"><i class="fa fa-check"></i><b>13.5.1</b> Knowing your data</a></li>
<li class="chapter" data-level="13.5.2" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#visual-inspection-of-linear-trends-1"><i class="fa fa-check"></i><b>13.5.2</b> Visual inspection of linear trends</a></li>
<li class="chapter" data-level="13.5.3" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#pearsons-r-1"><i class="fa fa-check"></i><b>13.5.3</b> Pearson’s r</a></li>
<li class="chapter" data-level="13.5.4" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#fit-models"><i class="fa fa-check"></i><b>13.5.4</b> Fit models</a></li>
<li class="chapter" data-level="13.5.5" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#using-processr"><i class="fa fa-check"></i><b>13.5.5</b> Using processR</a></li>
</ul></li>
<li class="chapter" data-level="13.6" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#take-aways-8"><i class="fa fa-check"></i><b>13.6</b> Take Aways</a></li>
<li class="chapter" data-level="13.7" data-path="tutorial-mediation-analysis.html"><a href="tutorial-mediation-analysis.html#additional-tutorials-7"><i class="fa fa-check"></i><b>13.7</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="14" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html"><i class="fa fa-check"></i><b>14</b> Exercise 5: Test your knowledge</a>
<ul>
<li class="chapter" data-level="14.1" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-1-4"><i class="fa fa-check"></i><b>14.1</b> Task 1</a></li>
<li class="chapter" data-level="14.2" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-2-4"><i class="fa fa-check"></i><b>14.2</b> Task 2</a></li>
<li class="chapter" data-level="14.3" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-3-4"><i class="fa fa-check"></i><b>14.3</b> Task 3</a></li>
<li class="chapter" data-level="14.4" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-4-3"><i class="fa fa-check"></i><b>14.4</b> Task 4</a></li>
<li class="chapter" data-level="14.5" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-5-3"><i class="fa fa-check"></i><b>14.5</b> Task 5</a></li>
<li class="chapter" data-level="14.6" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-6-2"><i class="fa fa-check"></i><b>14.6</b> Task 6</a></li>
<li class="chapter" data-level="14.7" data-path="exercise-5-test-your-knowledge.html"><a href="exercise-5-test-your-knowledge.html#task-7-1"><i class="fa fa-check"></i><b>14.7</b> Task 7</a></li>
</ul></li>
<li class="chapter" data-level="15" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html"><i class="fa fa-check"></i><b>15</b> Tutorial: Moderation analysis</a>
<ul>
<li class="chapter" data-level="15.1" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#introduction-to-moderation"><i class="fa fa-check"></i><b>15.1</b> Introduction to moderation</a></li>
<li class="chapter" data-level="15.2" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#one-step-process-of-moderation"><i class="fa fa-check"></i><b>15.2</b> One-step process of moderation</a></li>
<li class="chapter" data-level="15.3" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#statistical-representation-and-equations-1"><i class="fa fa-check"></i><b>15.3</b> Statistical representation and equations</a></li>
<li class="chapter" data-level="15.4" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#example-1"><i class="fa fa-check"></i><b>15.4</b> Example</a>
<ul>
<li class="chapter" data-level="15.4.1" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#knowing-your-data-2"><i class="fa fa-check"></i><b>15.4.1</b> Knowing your data</a></li>
<li class="chapter" data-level="15.4.2" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#visual-inspection-of-linear-trends-2"><i class="fa fa-check"></i><b>15.4.2</b> Visual inspection of linear trends</a></li>
<li class="chapter" data-level="15.4.3" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#fit-models-1"><i class="fa fa-check"></i><b>15.4.3</b> Fit models</a></li>
<li class="chapter" data-level="15.4.4" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#standardization-and-mean-centering"><i class="fa fa-check"></i><b>15.4.4</b> Standardization and mean-centering</a></li>
<li class="chapter" data-level="15.4.5" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#follow-up-analysis-pobing-the-interaction"><i class="fa fa-check"></i><b>15.4.5</b> Follow-up analysis: Pobing the interaction</a></li>
<li class="chapter" data-level="15.4.6" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#using-processr-1"><i class="fa fa-check"></i><b>15.4.6</b> Using processR</a></li>
</ul></li>
<li class="chapter" data-level="15.5" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#take-aways-9"><i class="fa fa-check"></i><b>15.5</b> Take Aways</a></li>
<li class="chapter" data-level="15.6" data-path="tutorial-moderation-analysis.html"><a href="tutorial-moderation-analysis.html#additional-tutorials-8"><i class="fa fa-check"></i><b>15.6</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="16" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html"><i class="fa fa-check"></i><b>16</b> Exercise 6: Test your knowledge</a>
<ul>
<li class="chapter" data-level="16.1" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-1-5"><i class="fa fa-check"></i><b>16.1</b> Task 1</a></li>
<li class="chapter" data-level="16.2" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-2-5"><i class="fa fa-check"></i><b>16.2</b> Task 2</a></li>
<li class="chapter" data-level="16.3" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-3-5"><i class="fa fa-check"></i><b>16.3</b> Task 3</a></li>
<li class="chapter" data-level="16.4" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-4-4"><i class="fa fa-check"></i><b>16.4</b> Task 4</a></li>
<li class="chapter" data-level="16.5" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-5-4"><i class="fa fa-check"></i><b>16.5</b> Task 5</a></li>
<li class="chapter" data-level="16.6" data-path="exercise-6-test-your-knowledge.html"><a href="exercise-6-test-your-knowledge.html#task-6-3"><i class="fa fa-check"></i><b>16.6</b> Task 6</a></li>
</ul></li>
<li class="chapter" data-level="17" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html"><i class="fa fa-check"></i><b>17</b> Tutorial: CPA and model fit</a>
<ul>
<li class="chapter" data-level="17.1" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#what-is-cpa"><i class="fa fa-check"></i><b>17.1</b> What is CPA?</a></li>
<li class="chapter" data-level="17.2" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#fitting-models-with-lavaan"><i class="fa fa-check"></i><b>17.2</b> Fitting models with lavaan</a></li>
<li class="chapter" data-level="17.3" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#example-evaluate-model-fit-for-complex-models"><i class="fa fa-check"></i><b>17.3</b> Example: Evaluate model fit for complex models</a>
<ul>
<li class="chapter" data-level="17.3.1" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#theory-driven-hypotheses"><i class="fa fa-check"></i><b>17.3.1</b> Theory-driven hypotheses</a></li>
<li class="chapter" data-level="17.3.2" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#model-fit-and-evaluation"><i class="fa fa-check"></i><b>17.3.2</b> Model fit and evaluation</a></li>
</ul></li>
<li class="chapter" data-level="17.4" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#take-aways-10"><i class="fa fa-check"></i><b>17.4</b> Take-Aways</a></li>
<li class="chapter" data-level="17.5" data-path="tutorial-cpa-and-model-fit.html"><a href="tutorial-cpa-and-model-fit.html#additional-tutorials-9"><i class="fa fa-check"></i><b>17.5</b> Additional tutorials</a></li>
</ul></li>
<li class="chapter" data-level="18" data-path="exercise-7-test-your-knowledge.html"><a href="exercise-7-test-your-knowledge.html"><i class="fa fa-check"></i><b>18</b> Exercise 7: Test your knowledge</a>
<ul>
<li class="chapter" data-level="18.1" data-path="exercise-7-test-your-knowledge.html"><a href="exercise-7-test-your-knowledge.html#task-1-6"><i class="fa fa-check"></i><b>18.1</b> Task 1</a></li>
<li class="chapter" data-level="18.2" data-path="exercise-7-test-your-knowledge.html"><a href="exercise-7-test-your-knowledge.html#task-2-6"><i class="fa fa-check"></i><b>18.2</b> Task 2</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html"><i class="fa fa-check"></i>Solutions</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-1"><i class="fa fa-check"></i>Solutions for Exercise 1</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-7"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-7"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-6"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-5"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-5"><i class="fa fa-check"></i>Task 5</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-2"><i class="fa fa-check"></i>Solutions for Exercise 2</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-8"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-8"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-7"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-6"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-6"><i class="fa fa-check"></i>Task 5</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-6-4"><i class="fa fa-check"></i>Task 6</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-7-2"><i class="fa fa-check"></i>Task 7</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-3"><i class="fa fa-check"></i>Solutions for Exercise 3</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-9"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-9"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-8"><i class="fa fa-check"></i>Task 3</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-4"><i class="fa fa-check"></i>Solutions for Exercise 4</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-10"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-10"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-9"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-7"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-7"><i class="fa fa-check"></i>Task 5</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-6-5"><i class="fa fa-check"></i>Task 6</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-5"><i class="fa fa-check"></i>Solutions for Exercise 5</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-11"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-11"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-10"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-8"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-8"><i class="fa fa-check"></i>Task 5</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-6-6"><i class="fa fa-check"></i>Task 6</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-7-3"><i class="fa fa-check"></i>Task 7</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-6"><i class="fa fa-check"></i>Solutions for Exercise 6</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-12"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-12"><i class="fa fa-check"></i>Task 2</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-3-11"><i class="fa fa-check"></i>Task 3</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-4-9"><i class="fa fa-check"></i>Task 4</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-5-9"><i class="fa fa-check"></i>Task 5</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-6-7"><i class="fa fa-check"></i>Task 6</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#solutions-for-exercise-7"><i class="fa fa-check"></i>Solutions for Exercise 7</a>
<ul>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-1-13"><i class="fa fa-check"></i>Task 1</a></li>
<li class="chapter" data-level="" data-path="solutions.html"><a href="solutions.html#task-2-13"><i class="fa fa-check"></i>Task 2</a></li>
</ul></li>
</ul></li>
<li class="divider"></li>
<li><a href="https://github.com/LKobilke/CPA-Seminar" target="blank">Published with bookdown</a></li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">R for Conditional Process Analysis</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div id="tutorial-installing-understanding-rr-studio" class="section level1" number="1">
<h1><span class="header-section-number"> 1</span> Tutorial: Installing & Understanding R/R Studio</h1>
<p>After working through Tutorial 1, you’ll…</p>
<ul>
<li>know how to install R and R Studio</li>
<li>know how to update R and R Studio</li>
<li>understand the main set-up of R Studio</li>
</ul>
<div id="installing-r" class="section level2" number="1.1">
<h2><span class="header-section-number">1.1</span> Installing R</h2>
<p>R is the programming language we’ll use to import, edit, and analyze data. Please watch one of these two video tutorials before installing R yourself.</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=_2sewGCA0y4">Video Tutorial for Windows</a></li>
<li><a href="https://www.youtube.com/watch?v=Y20P3u3c_1c">Video Tutorial for Mac</a></li>
</ul>
<p>When you are ready to install R, use <a href="https://cran.r-project.org/">Cran</a> to install the newest version of R (4.1.2, “Bird Hippie”). You’ll have to specify your operation system to download the right version:</p>
<ul>
<li><a href="https://cran.r-project.org/bin/windows/base/R-4.1.2-win.exe">Installer for Windows</a></li>
<li><a href="https://cran.r-project.org/bin/macosx/base/R-4.1.2.pkg">Installer for Mac</a></li>
</ul>
</div>
<div id="installing-r-studio" class="section level2" number="1.2">
<h2><span class="header-section-number">1.2</span> Installing R Studio</h2>
<p>Next, install R Studio. R Studio is a desktop application with a graphical interface that facilitates programming with R. The newest version of R Studio (1.4.1717) can be downloaded via this <a href="https://www.rstudio.com/products/rstudio/download/#download">Link</a>.</p>
</div>
<div id="updating-r-and-r-studio" class="section level2" number="1.3">
<h2><span class="header-section-number">1.3</span> Updating R and R Studio</h2>
<p>If you have already installed R and RStudio (for example, because you already needed it for a previous seminar), please update your version to the latest version. This way, we’ll all know that our versions are compatible.</p>
<div id="on-windows" class="section level3" number="1.3.1">
<h3><span class="header-section-number">1.3.1</span> On Windows</h3>
<p>Updating on Windows is tricky. Therefore, you can use a package called installr, which helps you manage your update.
First, install the installr package if you don’t have it. Use the following code:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="tutorial-installing-understanding-rr-studio.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># installing/loading the package:</span></span>
<span id="cb2-2"><a href="tutorial-installing-understanding-rr-studio.html#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span>(<span class="sc">!</span><span class="fu">require</span>(installr)) {</span>
<span id="cb2-3"><a href="tutorial-installing-understanding-rr-studio.html#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">install.packages</span>(<span class="st">"installr"</span>); </span>
<span id="cb2-4"><a href="tutorial-installing-understanding-rr-studio.html#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">require</span>(installr)</span>
<span id="cb2-5"><a href="tutorial-installing-understanding-rr-studio.html#cb2-5" aria-hidden="true" tabindex="-1"></a>} <span class="co">#load / install+load installr</span></span></code></pre></div>
<p>After you have installed or loaded the installr package, let’s start the updating process of your R installation by using the <code>updateR()</code> function. It will check for newer versions, and if one is available, will guide you through the decisions you’d need to make:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="tutorial-installing-understanding-rr-studio.html#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># using the package:</span></span>
<span id="cb3-2"><a href="tutorial-installing-understanding-rr-studio.html#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="fu">updateR</span>()</span></code></pre></div>
<p>Finally, update R Studio. Updating RStudio is easy, just open RStudio and go to <code>Help > Check for Updates</code> to install a newer version.</p>
</div>
<div id="on-mac" class="section level3" number="1.3.2">
<h3><span class="header-section-number">1.3.2</span> On MAC</h3>
<p>Go to <a href="https://www.r-project.org/">CRAN</a> and install the newer package intaller.</p>
<p>After that update R Studio. Updating RStudio is easy, just open RStudio and go to <code>Help > Check for Updates</code> to install a newer version.</p>
</div>
</div>
<div id="how-does-r-work" class="section level2" number="1.4">
<h2><span class="header-section-number">1.4</span> How does R work?</h2>
<p>First things first: R is an object- and function-oriented programming language. Chambers <a href="https://arxiv.org/pdf/1409.3531.pdf">(2014, p. 4)</a> has nicely summarized what this means:</p>
<ul>
<li>Everything that exists is an object.</li>
<li>Everything that happens is a function call.</li>
</ul>
<p>We assign values (for instance, single numbers/letters, several numbers/letters, or whole data sets) to objects in R to work with them/do computations. For instance, the following command in R would assign the word “hello” to the object <em>word</em> by using the <em><-</em> sign (a function used for assigning values to objects):</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="tutorial-installing-understanding-rr-studio.html#cb4-1" aria-hidden="true" tabindex="-1"></a>word <span class="ot"><-</span> <span class="st">"hello"</span></span></code></pre></div>
<p>Objects have specific properties that determine which types of calculations can be done with them (and which cannot). For instance, the object <em>word</em> is characterized by the fact that it consists of characters (i.e., a word) - which may, for instance, prohibit you to calculate the mean of this object (which is something only possible for objects consisting of numeric data).</p>
<p>This already hints towards the second, important aspect of R: It is influenced by functional programming, meaning that everything we <em>do</em> in R is a function call. R uses functions to assign specific values (for instance, a single number or word, several numbers or words, whole data sets) to objects. In short, what you will learn by learning programming in R is how to write functions for making R do the calculations you need.</p>
<p>Let’s take SPSS - which, I assume, many of you have worked with previously - as a comparison. If you import, edit, or analyze a data set in SPSS, you’ll use the click-and-point menu to change variable values, calculate variables’ means, or export data.</p>
<p>R works differently: You assign the data set to an object - for instance an object called “word”, as done previously. This assignment enables you to work with the data: You can now call specific functions to work with or change this object. For instance, if you want to add another word to the object <em>word</em>, for instance “and good morning”, you could do that by using a specific function called <em>paste0()</em>, which takes the original object <em>word</em> and adds your additional words ” and good morning” to overwrite the old object <em>word</em>:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="tutorial-installing-understanding-rr-studio.html#cb5-1" aria-hidden="true" tabindex="-1"></a>word <span class="ot"><-</span> <span class="fu">paste0</span>(word, <span class="st">" and good morning"</span>)</span>
<span id="cb5-2"><a href="tutorial-installing-understanding-rr-studio.html#cb5-2" aria-hidden="true" tabindex="-1"></a>word</span></code></pre></div>
<pre><code>## [1] "hello and good morning"</code></pre>
<p>Different to using the click-and-point menu in SPSS, you thus <strong>need to write your own code</strong> to import, edit, or analyze any type of data in R. Luckily, R already includes a lot of predefined functions meaning that we do not have write all of these functions ourselves.</p>
<p><strong>Ouch, that seems awfully complicated. Why should I use R?</strong></p>
<p>There are several reasons why I’m an advocate of R (or similar programming languages such as Python) over programs such as SPSS.</p>
<ol style="list-style-type: decimal">
<li><p>R is free. Other than most other (statistical) programs, you do not need to buy it (or rely on an university license, that is likely to run out once you leave your department).</p></li>
<li><p>R is an open source program. Other than most other programs, the source code - i.e., the basis of the program - is freely available. So are the hundred of packages (we’ll get to those later - these are basically additional functions you may need for more specific analyses) on CRAN that you can use to extend R’s base functions.</p></li>
<li><p>R offers you flexibility. You can work with almost any type of data and rely on a large (!) set of functions to import, edit, or analyze such data. And if the function you need to do so hasn’t been implemented (or simply does not exist yet), you can write it yourself!</p></li>
<li><p>Learning R increases your chances on the job market. For many jobs (academia, market research, data science, data journalism), applicants should know at least one programming language.</p></li>
</ol>
</div>
<div id="how-does-r-studio-work" class="section level2" number="1.5">
<h2><span class="header-section-number">1.5</span> How does R Studio work?</h2>
<iframe src="https://www.youtube.com/embed/RYNiJpTfy-o" width="672" height="400px" data-external="1">
</iframe>
<p>As mentioned, R studio is a graphical interface which facilitates programming with R. It contains up to four main windows, which allow for different things:</p>
<ul>
<li>Writing your own code (Window 1: Source).
<strong>Important</strong>: When first installing R/R Studio and opening R studio, you may not see this window right away. In this case, simply open it by clicking on <em>File/New File/R Script</em>.</li>
<li>Executing your own code (Window 2: Console)</li>
<li>Inspecting objects (Window 3: Environment)</li>
<li>Visualizing data, searching for help, updating packages etc. (Window 4: Files/Plots/Packages etc.)</li>
</ul>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Image: Four main windows in R</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut1_Overview.jpg" /></td>
</tr>
</tbody>
</table>
<p>Please note that the specific set-up of your R Studio may look different (the order of windows may vary and so may the windows’ names). I have made the experience that having these four windows open works best for me. This may be different for you. If you want to modify the appearance of your R Studio, simply choose <em>“Tools/Global Options/Pane Layout”</em>.</p>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Image: Changing the Layout</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut1_Change.JPG" /></td>
</tr>
</tbody>
</table>
<div id="source-writing-your-own-code" class="section level3" number="1.5.1">
<h3><span class="header-section-number">1.5.1</span> Source: Writing your own code</h3>
<p>Using the window “Source”, you’ll write your own code to execute whichever task you want R to fulfill.</p>
<div id="writing-code" class="section level4" number="1.5.1.1">
<h4><span class="header-section-number">1.5.1.1</span> Writing Code</h4>
<p>Let’s start with an easy example: Assume you simply want R to print the word “hello”. In this case, you would first write a simple command that assigns the word “hello” to an object called <em>word</em>. The assigment of values to named objects is done via either the operator “<-” or the operator “=”. The left side of that command contains the object that should be created; its right side the values that should be assigned to this object.</p>
<p>In short, this command tells R to assign the world “hello” to an object called <em>word</em>.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="tutorial-installing-understanding-rr-studio.html#cb7-1" aria-hidden="true" tabindex="-1"></a>word <span class="ot"><-</span> <span class="st">"hello"</span></span></code></pre></div>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Image: “Source”</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut1_Source%20Panel.jpg" /></td>
</tr>
</tbody>
</table>
</div>
<div id="annotating-code" class="section level4" number="1.5.1.2">
<h4><span class="header-section-number">1.5.1.2</span> Annotating Code</h4>
<p>Another helpful aspect of R is that you can comment your own code. Oftentimes, this is very helpful for understanding your code later (if you write several hundred lines of codes, you may not remember their exact meaning months later).</p>
<p>Comments or notes can be made via hashtags #. Anything following a hashtag will not be considered code by R but be ignored instead.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="tutorial-installing-understanding-rr-studio.html#cb8-1" aria-hidden="true" tabindex="-1"></a>word <span class="ot"><-</span> <span class="st">"hello"</span> <span class="co">#this line of code assigns the word "hello" to an object called word</span></span></code></pre></div>
</div>
<div id="executing-code" class="section level4" number="1.5.1.3">
<h4><span class="header-section-number">1.5.1.3</span> Executing Code</h4>
<p>We now want to execute our code. Doing so is simple:</p>
<ul>
<li>Mark the parts of the code you want to run (for instance, single rows of code or blocks of code across several rows)</li>
<li>Either press <em>Run</em> (see upper right side of the same window) or press <strong>Ctrl + Enter</strong> (On Mac OS X, hold the command key and press return instead).</li>
</ul>
<p>R should now execute exactly those lines of codes that you marked (hereby creating the object <em>word</em>). If you haven’t marked any specific code, all lines of code will be executed.</p>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Image: Executing Code</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut1_Execute.jpg" /></td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="console-printing-results" class="section level3" number="1.5.2">
<h3><span class="header-section-number">1.5.2</span> Console: Printing results</h3>
<p>Results of executing code are printed in a second window called “Console”, which includes the code you ran and the object you may have called when doing so.</p>
<p>Previously, we defined an object called word, which consists of the single word “hello”. Thus, R prints our code as well as objects called when running this code (here, the object word) in the console.</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="tutorial-installing-understanding-rr-studio.html#cb9-1" aria-hidden="true" tabindex="-1"></a>word <span class="ot"><-</span> <span class="st">"hello"</span></span>
<span id="cb9-2"><a href="tutorial-installing-understanding-rr-studio.html#cb9-2" aria-hidden="true" tabindex="-1"></a>word</span></code></pre></div>
<pre><code>## [1] "hello"</code></pre>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Image: Window “Console”</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut1_Konsole%20Panel.JPG" /></td>
</tr>
</tbody>
</table>
</div>
<div id="environment-overview-of-objects" class="section level3" number="1.5.3">
<h3><span class="header-section-number">1.5.3</span> Environment: Overview of objects</h3>
<p>The third window is called “Environment”<a href="#fn1" class="footnote-ref" id="fnref1"><sup>1</sup></a>. This windows displays all the objects currently existing - in our case, only the object “word”. As soon as you start creating more objects, this environment will fill up.</p>
<p>If you’re an SPSS user, this window is very similar to what is called the <em>Datenansicht / Data overview</em> in SPSS. However, the R version of this is much more flexible, given that our environment can contain several data sets, for example, at the same time.</p>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Image: Window “Environment”</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut1_Environment%20Panel.JPG" /></td>
</tr>
</tbody>
</table>
<p>It is important to know that we can visually inspect any object using the <em>View()</em> command (with a new tab then opening in the “Source” window). This isn’t super helpful right now - but if you work with bigger data sets with several observations/variables later on, it is often useful to inspect data visually.</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="tutorial-installing-understanding-rr-studio.html#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">View</span>(word)</span></code></pre></div>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Image: Window “View”</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut1_View.jpg" /></td>
</tr>
</tbody>
</table>
</div>
<div id="plotshelppackages-do-everything-else" class="section level3" number="1.5.4">
<h3><span class="header-section-number">1.5.4</span> Plots/Help/Packages: Do everything else</h3>
<p>Lastly, the standard R Studio interface contains a fourth window (if you opted for this layout). In my case, the window contains several sub-sections called “Files”, “Plots”, or “Packages” among others. You’ll understand their specific functions later - the window can, for instance, be used to plot/visualize results or see which packages are currently loaded.</p>
<table>
<colgroup>
<col width="100%" />
</colgroup>
<tbody>
<tr class="odd">
<td align="left"><em>Image: Window “Files/Plots/Packages”</em></td>
</tr>
<tr class="even">
<td align="left"><img src="images/Tut1_Files%20Plots%20Packages.JPG" /></td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="take-aways" class="section level2" number="1.6">
<h2><span class="header-section-number">1.6</span> Take-Aways</h2>
<ul>
<li><strong>Window “Source”</strong>: used to write/execute code in R</li>
<li><strong>Window “Console”</strong>: used to return results of executed code</li>
<li><strong>Window “Environment”</strong>: used to inspect objects on which to use functions</li>
<li><strong>Window “Files/Plots/Packages etc.”</strong>: used for additional functions, for instance visualizations/searching for help/activating or updating packages</li>
</ul>
</div>
<div id="additional-tutorials" class="section level2" number="1.7">
<h2><span class="header-section-number">1.7</span> Additional tutorials</h2>
<p>You still have questions? The following tutorials & papers can help you with that:</p>
<ul>
<li><a href="https://bookdown.org/ndphillips/YaRrr/started.html">YaRrr! The Pirate’s Guide to R by N.D.Phillips, Tutorial 2</a></li>
<li><a href="https://bookdown.org/joone/ComputationalMethods/firststeps.html">Computational Methods in der politischen Kommunikationsforschung by J. Unkel, Tutorial 1</a></li>
<li><a href="https://sicss.io/boot_camp#install">SICSS Boot Camp by C. Bail, Video 1</a></li>
<li><a href="https://youtu.be/p6f4oq08z48">wegweisR by M. Haim, Video 1</a></li>
<li><a href="https://rc2e.com/gettingstarted#recipe-id001">R Cookbook by Long et al., Tutorial 1</a></li>
</ul>
<p>Let’s keep going: [Tutorial 2: Workflow in R]</p>
</div>
</div>
<div class="footnotes">
<hr />
<ol start="1">
<li id="fn1"><p>again, this only applies for the way I set up my R Studio. You can change this via <em>“Tools/Global Options/Pane Layout”</em><a href="tutorial-installing-understanding-rr-studio.html#fnref1" class="footnote-back">↩︎</a></p></li>
</ol>
</div>
</section>
</div>
</div>
</div>
<a href="index.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="tutorial-workflow-in-r.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
</div>
</div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/clipboard.min.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-clipboard.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": false,
"facebook": true,
"twitter": true,
"linkedin": false,
"weibo": false,
"instapaper": false,
"vk": false,
"whatsapp": false,
"all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": "https://github.com/LKobilke/CPA-Seminar/edit/main/index.Rmd",
"text": "Edit"
},
"history": {
"link": null,
"text": null
},
"view": {
"link": null,
"text": null
},
"download": ["CPA Seminar.pdf"],
"search": {
"engine": "fuse",
"options": null
},
"toc": {
"collapse": "subsection"
}
});
});
</script>
</body>
</html>