-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathInstall-R-and-RStudio-2026.html
More file actions
1593 lines (1378 loc) · 71 KB
/
Install-R-and-RStudio-2026.html
File metadata and controls
1593 lines (1378 loc) · 71 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Install R & RStudio in 2026: The Setup That Actually Works First Time</title>
<meta charset="utf-8">
<meta name="Description" content="Step-by-step R and RStudio installation for Windows, Mac, and Linux. First-run settings, common errors fixed, and a verify-it-works checklist.">
<meta name="Keywords" content="install R, install RStudio, R installation, download R, RStudio setup, R Windows, R Mac, R Linux">
<meta name="Distribution" content="Global">
<meta name="Author" content="Selva Prabhakaran">
<meta name="Robots" content="index, follow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/screenshots/iconb-64.png" type="image/x-icon" />
<link rel="canonical" href="https://r-statistics.co/Install-R-and-RStudio-2026.html">
<link rel="alternate" type="application/atom+xml" title="r-statistics.co" href="https://r-statistics.co/feed.xml">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preconnect" href="https://cdnjs.cloudflare.com">
<!-- Critical CSS inlined for fast first paint -->
<style>
*,*::before,*::after{box-sizing:border-box}
body{margin:0;font-family:'IBM Plex Sans',-apple-system,BlinkMacSystemFont,sans-serif;font-size:16px;line-height:1.5;color:#1a1a2e;background:#fdfdfd}
.container{max-width:1170px;margin:0 auto;padding:0 15px}
.row{margin-left:-15px;margin-right:-15px}.row::after{content:"";display:table;clear:both}
.col-xs-12,.col-sm-2,.col-sm-3,.col-sm-7{position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left}
.col-xs-12{width:100%}
@media(min-width:768px){.col-sm-2{width:16.667%}.col-sm-3{width:25%}.col-sm-7{width:58.333%}.hidden-xs{display:block!important}}
.hidden-xs{display:none}
.table{width:100%;border-collapse:collapse}.table>thead>tr>th,.table>tbody>tr>td{padding:8px;border-top:1px solid #ddd}
.table-striped>tbody>tr:nth-of-type(odd){background:#f9f9f9}
.btn{display:inline-block;padding:6px 12px;font-size:14px;border-radius:4px;cursor:pointer;border:1px solid transparent}
.btn-primary{color:#fff;background:#3f73d8;border-color:#3f73d8}.btn-primary:hover{background:#2c5fbe}
.btn-default{color:#333;background:#fff;border-color:#ccc}
.btn-sm{padding:3px 10px;font-size:12px}
.form-control{display:block;padding:6px 12px;font-size:14px;border:1px solid #ccc;border-radius:4px}
.list-unstyled{list-style:none;padding-left:0}
.img-responsive{max-width:100%;height:auto}
.pull-right{float:right}
a{color:#3F73D8;text-decoration:none}a:hover{text-decoration:underline}
html,body{overflow-x:hidden;max-width:100vw}
</style>
<!-- Full Bootstrap deferred (non-render-blocking) -->
<link href="www/bootstrap.min.css" rel="stylesheet" media="print" onload="this.media='all'">
<noscript><link href="www/bootstrap.min.css" rel="stylesheet"></noscript>
<link href="www/highlight.css" rel="stylesheet" media="print" onload="this.media='all'">
<link href="css/main.css?v=14" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Serif:wght@600;700&family=IBM+Plex+Mono:wght@400;500&display=swap"
rel="stylesheet" media="print" onload="this.media='all'">
<noscript><link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Serif:wght@600;700&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet"></noscript>
<!-- Color Script -->
<style type="text/css">
a {
color: #3F73D8;
}
li {
line-height: 1.65;
}
/* reduce spacing around math formula*/
.MathJax_Display {
margin: 0em 0em;
}
/* Wider container for better content space */
@media (min-width: 1200px) {
.container { max-width: 1280px; }
}
/* Column layout */
#nav, #content, #toc-sidebar { box-sizing: border-box; }
#content {
padding-left: 15px;
padding-right: 15px;
overflow-wrap: break-word;
word-wrap: break-word;
overflow: hidden;
}
/* On mobile: hide sidebar, show hamburger, mobile overlay */
@media (max-width: 767px) {
#nav { display: none; }
#mobile-menu-btn { display: block !important; }
.site-header h3 { font-size: 16px !important; }
.site-header h3 small { display: none !important; }
.site-header form { display: none; }
}
@media (max-width: 400px) {
.site-header h3 { font-size: 14px !important; }
}
/* Mobile sidebar overlay */
.mobile-sidebar-overlay {
display: none;
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
z-index: 9999;
background: rgba(0,0,0,0.4);
}
.mobile-sidebar-overlay.open { display: block; }
.mobile-sidebar-panel {
position: fixed;
top: 0; left: 0; bottom: 0;
width: 280px;
background: #fff;
z-index: 10000;
overflow-y: auto;
padding: 16px;
box-shadow: 2px 0 16px rgba(0,0,0,0.15);
transform: translateX(-100%);
transition: transform 0.25s ease;
}
.mobile-sidebar-overlay.open .mobile-sidebar-panel { transform: translateX(0); }
.mobile-sidebar-close {
position: absolute; top: 10px; right: 12px;
background: none; border: none; font-size: 22px; cursor: pointer; color: #666;
}
html.dark .mobile-sidebar-panel { background: #1e293b; }
html.dark .mobile-sidebar-overlay { background: rgba(0,0,0,0.6); }
html.dark .mobile-sidebar-close { color: #94a3b8; }
</style>
<!-- Open Graph -->
<meta property="og:title" content="Install R & RStudio in 2026: The Setup That Actually Works First Time">
<meta property="og:description" content="Step-by-step R and RStudio installation for Windows, Mac, and Linux. First-run settings, common errors fixed, and a verify-it-works checklist.">
<meta property="og:type" content="article">
<meta property="og:url" content="https://r-statistics.co/Install-R-and-RStudio-2026.html">
<meta property="og:site_name" content="r-statistics.co">
<meta property="og:image" content="https://r-statistics.co/screenshots/og/Install-R-and-RStudio-2026.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Install R & RStudio in 2026: The Setup That Actually Works First Time">
<meta name="twitter:description" content="Step-by-step R and RStudio installation for Windows, Mac, and Linux. First-run settings, common errors fixed, and a verify-it-works checklist.">
<meta name="twitter:image" content="https://r-statistics.co/screenshots/og/Install-R-and-RStudio-2026.png">
<!-- JSON-LD Structured Data -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": ["TechArticle", "LearningResource"],
"headline": "Install R & RStudio in 2026: The Setup That Actually Works First Time",
"description": "Step-by-step R and RStudio installation for Windows, Mac, and Linux. First-run settings, common errors fixed, and a verify-it-works checklist.",
"author": {"@type": "Person", "name": "Selva Prabhakaran", "url": "https://r-statistics.co/about/", "jobTitle": "Data Scientist"},
"publisher": {"@type": "Organization", "name": "r-statistics.co", "url": "https://r-statistics.co/", "logo": {"@type": "ImageObject", "url": "https://r-statistics.co/screenshots/og-default.png"}},
"url": "https://r-statistics.co/Install-R-and-RStudio-2026.html",
"datePublished": "2026-03-29",
"dateModified": "2026-03-29",
"inLanguage": "en",
"educationalLevel": "Intermediate",
"programmingLanguage": "R",
"speakable": {"@type": "SpeakableSpecification", "cssSelector": [".lead", "#content h1"]}
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": "https://r-statistics.co/"},
{"@type": "ListItem", "position": 2, "name": "Learn R"},
{"@type": "ListItem", "position": 3, "name": "Install R & RStudio in 2026: The Setup That Actually Works First Time", "item": "https://r-statistics.co/Install-R-and-RStudio-2026.html"}
]
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{"@type": "Question", "name": "Do I need to install R if I only want RStudio?", "acceptedAnswer": {"@type": "Answer", "text": "Yes. RStudio is just an editor — it doesn't include R itself. You must install R first (from CRAN), then install RStudio. RStudio will automatically detect and use your R installation."}},
{"@type": "Question", "name": "Can I have multiple versions of R installed?", "acceptedAnswer": {"@type": "Answer", "text": "Yes. On Windows and Mac, each R version installs to its own folder. In RStudio, go to Tools → Global Options → General → R version to switch between them. This is useful when a project requires a specific R version."}},
{"@type": "Question", "name": "How do I update R to a new version?", "acceptedAnswer": {"@type": "Answer", "text": "Download and install the new version from CRAN — it installs alongside the old one. Then reinstall your packages. On Windows, the installr package can automate this: installr::updateR()."}},
{"@type": "Question", "name": "Is RStudio really free?", "acceptedAnswer": {"@type": "Answer", "text": "Yes. RStudio Desktop (the open-source edition) is completely free and always will be. Posit (the company) makes money from RStudio Server Pro, Posit Connect, and cloud services — not from the desktop IDE."}},
{"@type": "Question", "name": "Can I use R without RStudio?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, but you probably shouldn't as a beginner. You can run R from the command line, or use other editors like VS Code (with the R extension) or Positron. But RStudio is purpose-built for R and provides the best experience for beginners: integrated help, variable explorer, plot viewer, and package manager all in one window."}}
]
}
</script>
<!-- WebR Interactive R Code -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/codemirror.min.css">
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
<style>
/* --- Loading banner: compact, collapses when ready --- */
.webr-loading-banner {
padding: 8px 16px;
background: #f0f4ff;
color: #3b5998;
text-align: center;
margin: 0 0 8px 0;
border-radius: 6px;
font-size: 13px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
border: 1px solid #c7d2fe;
transition: all 0.4s ease;
overflow: hidden;
max-height: 50px;
}
.webr-loading-banner.ready {
background: #ecfdf5;
color: #166534;
border-color: #86efac;
}
.webr-loading-banner.hidden {
max-height: 0;
padding: 0 16px;
margin: 0;
border-color: transparent;
opacity: 0;
}
/* --- Run All bar (subtle with background) --- */
.webr-runall-bar {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 10px;
padding: 7px 14px;
margin: 0 0 18px 0;
background: #f8fafb;
border: 1px solid #edf0f3;
border-radius: 8px;
opacity: 0;
transform: translateY(-4px);
transition: opacity 0.3s ease, transform 0.3s ease;
}
.webr-runall-bar.visible { opacity: 1; transform: translateY(0); }
.webr-runall-label {
font-size: 11px;
color: #9ca3af;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
display: flex;
align-items: center;
gap: 5px;
}
.webr-runall-label::before {
content: '';
width: 6px; height: 6px;
border-radius: 50%;
background: #2da44e;
flex-shrink: 0;
}
.webr-runall-btn {
background: none;
color: #3f73d8;
border: 1px solid #d0d7de;
padding: 4px 12px;
border-radius: 6px;
font-size: 11px;
font-weight: 400;
cursor: pointer;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
transition: all 0.15s ease;
}
.webr-runall-btn:hover { background: #f6f8fa; border-color: #3f73d8; }
.webr-runall-btn:disabled { color: #a5b4d4; cursor: wait; }
.webr-runall-btn.running { color: #d29922; border-color: #d29922; animation: pulse-run 1.5s ease-in-out infinite; }
/* --- Code block container --- */
.webr-container {
margin: 22px 0;
border: 1px solid #e1e4e8;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 0 1px rgba(0,0,0,0.1);
transition: box-shadow 0.2s ease;
}
.webr-container:hover {
box-shadow: 0 4px 16px rgba(0,0,0,0.1), 0 0 1px rgba(0,0,0,0.12);
border-color: #c7d2fe;
}
.webr-container:focus-within {
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59,130,246,0.15), 0 2px 8px rgba(0,0,0,0.06);
}
/* --- Code block header bar --- */
.webr-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 5px 12px;
background: #f1f5f9;
border-bottom: 1px solid #e2e8f0;
font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.webr-header-label {
font-size: 11px; font-weight: 600; color: #64748b;
text-transform: uppercase; letter-spacing: 0.5px;
}
.webr-header-badge {
background: #3b82f6; color: #fff; padding: 1px 8px;
border-radius: 4px; font-size: 10px; font-weight: 600; letter-spacing: 0.3px;
}
/* --- Run button shortcut hint --- */
.webr-run-shortcut {
font-size: 10px; opacity: 0.7; margin-left: 6px; font-weight: 400;
}
/* --- Button bar (below code editor) --- */
.webr-buttons {
padding: 6px 10px;
background: #f7f8fa;
border-top: 1px solid #e1e4e8;
display: flex;
justify-content: space-between;
align-items: center;
}
.webr-buttons-left { display: flex; gap: 6px; align-items: center; }
.webr-buttons-right { display: flex; gap: 6px; align-items: center; }
/* --- Keyboard hint --- */
.webr-kbd-hint {
font-size: 10px;
color: #9ca3af;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.webr-kbd-hint kbd {
background: #f0f1f3;
border: 1px solid #d1d5db;
border-radius: 3px;
padding: 1px 4px;
font-size: 10px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}
/* --- Copy button --- */
.webr-copy-btn {
background: none;
border: 1px solid #d0d7de;
color: #656d76;
padding: 3px 7px;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
transition: all 0.15s ease;
display: flex;
align-items: center;
gap: 4px;
line-height: 1;
}
.webr-copy-btn:hover { background: #f6f8fa; color: #24292f; border-color: #c0c8d0; }
.webr-copy-btn.copied { color: #2da44e; border-color: #2da44e; }
/* --- Pre-CodeMirror: reserve space to prevent CLS --- */
.webr-editor {
min-height: 80px;
font-family: 'IBM Plex Mono', 'JetBrains Mono', 'Consolas', monospace;
font-size: 14px;
line-height: 1.6;
padding: 8px 12px 8px 40px;
background: #fafbfd;
white-space: pre;
overflow: hidden;
color: #24292f;
}
/* After CodeMirror initializes, it replaces the content — reset padding */
.webr-editor .CodeMirror {
height: auto;
min-height: 48px;
font-size: 14px;
font-family: 'IBM Plex Mono', 'JetBrains Mono', 'Consolas', monospace;
line-height: 1.6;
background: #fafbfd;
padding: 4px 0;
}
.webr-editor.cm-initialized { padding: 0; min-height: auto; }
.webr-editor .CodeMirror-gutters {
background: #f0f2f5;
border-right: 1px solid #e1e4e8;
padding-right: 2px;
}
.webr-editor .CodeMirror-linenumber {
color: #a0a8b4;
font-size: 11px;
padding: 0 6px 0 8px;
min-width: 28px;
}
.webr-editor .CodeMirror-cursor { border-left-color: #3b82f6; border-left-width: 2px; }
.webr-editor .CodeMirror-selected { background: #c8e1ff !important; }
.webr-editor .CodeMirror-activeline-background { background: #f0f4ff; }
.webr-editor .CodeMirror-matchingbracket { color: #0969da !important; font-weight: 700; background: #ddf4ff; border-radius: 2px; }
/* --- R syntax colors (refined) --- */
.webr-editor .cm-keyword { color: #cf222e; font-weight: 500; }
.webr-editor .cm-atom { color: #8250df; }
.webr-editor .cm-number { color: #0550ae; }
.webr-editor .cm-def { color: #8250df; }
.webr-editor .cm-variable { color: #24292f; }
.webr-editor .cm-variable-2 { color: #953800; }
.webr-editor .cm-variable-3 { color: #0550ae; }
.webr-editor .cm-property { color: #0550ae; }
.webr-editor .cm-operator { color: #cf222e; }
.webr-editor .cm-comment { color: #6e7781; font-style: italic; }
.webr-editor .cm-string { color: #0a3069; }
.webr-editor .cm-string-2 { color: #0a3069; }
.webr-editor .cm-builtin { color: #8250df; font-weight: 500; }
/* --- Run button --- */
.webr-run-btn {
background: #3f73d8;
color: #fff;
border: none;
padding: 4px 14px;
border-radius: 6px;
font-size: 12px;
font-weight: 500;
cursor: pointer;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
transition: all 0.15s ease;
}
.webr-run-btn:hover { background: #2c5fbe; }
.webr-run-btn:active { background: #254fa0; }
.webr-run-btn:disabled { background: #a5b4d4; cursor: wait; }
.webr-run-btn.running { background: #d29922; animation: pulse-run 1.5s ease-in-out infinite; }
@keyframes pulse-run { 0%, 100% { opacity: 1; } 50% { opacity: 0.8; } }
/* --- Reset button --- */
.webr-reset-btn {
background: none;
color: #656d76;
border: 1px solid #d0d7de;
padding: 3px 10px;
border-radius: 6px;
font-size: 12px;
cursor: pointer;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
transition: all 0.15s ease;
}
.webr-reset-btn:hover { background: #f6f8fa; color: #24292f; border-color: #c0c8d0; }
/* --- Output panel --- */
.webr-output {
margin: 0;
padding: 14px 16px;
background: #f1f5f9;
color: #1e293b;
font-family: 'IBM Plex Mono', 'JetBrains Mono', 'Consolas', monospace;
font-size: 13px;
line-height: 1.6;
max-height: 400px;
overflow-y: auto;
white-space: pre-wrap;
display: none;
border-top: 1px solid #e2e8f0;
}
.webr-output::-webkit-scrollbar { width: 8px; }
.webr-output::-webkit-scrollbar-track { background: #f1f5f9; }
.webr-output::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.webr-output.has-content { display: block; }
.webr-output.has-error { color: #dc2626; border-top-color: #dc2626; }
/* --- Plot output --- */
.webr-plot-output { text-align: center; padding: 16px; background: #fff; display: none; border-top: 1px solid #e1e4e8; }
.webr-plot-output.has-content { display: block; }
.webr-plot-output img, .webr-plot-output canvas { max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.mermaid { margin: 15px 0; text-align: center; }
/* ===== DARK MODE — WebR components ===== */
/* Loading banner */
html.dark .webr-loading-banner { background: #1e293b; color: #94a3b8; border-color: #334155; }
html.dark .webr-loading-banner.ready { background: #1e293b; color: #4ade80; border-color: #334155; }
/* Run All bar */
html.dark .webr-runall-bar { background: #1e293b; border-color: #334155; }
html.dark .webr-runall-label { color: #94a3b8; }
html.dark .webr-runall-label::before { background: #4ade80; }
html.dark .webr-runall-btn { color: #94a3b8; border-color: #475569; }
html.dark .webr-runall-btn:hover { background: #334155; color: #e2e8f0; border-color: #3b82f6; }
/* Container */
html.dark .webr-container { border-color: #334155; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
html.dark .webr-container:hover { border-color: #4f46e5; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
html.dark .webr-container:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }
/* Header bar */
html.dark .webr-header { background: #0f172a; border-bottom-color: #1e293b; }
html.dark .webr-header-label { color: #64748b; }
html.dark .webr-header-badge { background: #3b82f6; color: #fff; }
/* Button bar */
html.dark .webr-buttons { background: #0f172a; border-top-color: #1e293b; }
/* Run button */
html.dark .webr-run-btn { background: #3b82f6; }
html.dark .webr-run-btn:hover { background: #2563eb; }
html.dark .webr-run-shortcut { opacity: 0.6; }
/* Reset button */
html.dark .webr-reset-btn { color: #94a3b8; border-color: #475569; }
html.dark .webr-reset-btn:hover { background: #334155; color: #e2e8f0; }
/* Copy button */
html.dark .webr-copy-btn { color: #94a3b8; border-color: #475569; }
html.dark .webr-copy-btn:hover { background: #334155; color: #e2e8f0; border-color: #64748b; }
html.dark .webr-copy-btn.copied { color: #4ade80; border-color: #4ade80; }
/* CodeMirror editor */
html.dark .webr-editor .CodeMirror { background: #1e293b; color: #e2e8f0; }
html.dark .webr-editor .CodeMirror-gutters { background: #1e293b; border-right-color: #334155; }
html.dark .webr-editor .CodeMirror-linenumber { color: #475569; }
html.dark .webr-editor .CodeMirror-cursor { border-left-color: #60a5fa; }
html.dark .webr-editor .CodeMirror-selected { background: #334155 !important; }
html.dark .webr-editor .CodeMirror-activeline-background { background: #1e3a5f; }
html.dark .webr-editor .CodeMirror-matchingbracket { color: #60a5fa !important; background: #1e3a5f; }
html.dark .webr-editor .cm-keyword { color: #f87171; }
html.dark .webr-editor .cm-atom { color: #c084fc; }
html.dark .webr-editor .cm-number { color: #60a5fa; }
html.dark .webr-editor .cm-def { color: #c084fc; }
html.dark .webr-editor .cm-variable { color: #e2e8f0; }
html.dark .webr-editor .cm-variable-2 { color: #fb923c; }
html.dark .webr-editor .cm-variable-3 { color: #60a5fa; }
html.dark .webr-editor .cm-property { color: #60a5fa; }
html.dark .webr-editor .cm-operator { color: #f87171; }
html.dark .webr-editor .cm-comment { color: #64748b; }
html.dark .webr-editor .cm-string { color: #86efac; }
html.dark .webr-editor .cm-string-2 { color: #86efac; }
html.dark .webr-editor .cm-builtin { color: #c084fc; }
/* Output panel */
html.dark .webr-output { background: #0f172a; color: #cbd5e1; border-top-color: #1e293b; }
html.dark .webr-output::-webkit-scrollbar-track { background: #0f172a; }
html.dark .webr-output::-webkit-scrollbar-thumb { background: #475569; }
html.dark .webr-output.has-error { color: #f87171; border-top-color: #f87171; }
/* Plot output */
html.dark .webr-plot-output { background: #1e293b; border-top-color: #334155; }
/* Kbd hint */
html.dark .webr-kbd-hint { color: #64748b; }
html.dark .webr-kbd-hint kbd { background: #334155; border-color: #475569; color: #94a3b8; }
</style>
<!-- Add Google search -->
<script language="Javascript" type="text/javascript">
function my_search_google()
{
var query = document.getElementById("my-google-search").value;
window.open("https://google.com/search?q=" + query
+ "%20site:" + "https://r-statistics.co");
}
</script>
</head>
<body>
<!-- Mobile sidebar overlay -->
<div class="mobile-sidebar-overlay" id="mobile-sidebar">
<div class="mobile-sidebar-panel">
<button class="mobile-sidebar-close" id="mobile-sidebar-close">×</button>
<div id="mobile-sidebar-content">
<!-- Populated by toc.js -->
</div>
</div>
</div>
<div class="container">
<div class="masthead">
<!--
<ul class="nav nav-pills pull-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Table of contents<b class="caret"></b>
</a>
<ul class="dropdown-menu pull-right" role="menu">
<li class="dropdown-header"></li>
<li class="dropdown-header">Tutorial</li>
<li><a href="R-Tutorial.html">R Tutorial</a></li>
<li class="dropdown-header">ggplot2</li>
<li><a href="ggplot2-Tutorial-With-R.html">ggplot2 Short Tutorial</a></li>
<li><a href="Complete-Ggplot2-Tutorial-Part1-With-R-Code.html">ggplot2 Tutorial 1 - Intro</a></li>
<li><a href="Complete-Ggplot2-Tutorial-Part2-Customizing-Theme-With-R-Code.html">ggplot2 Tutorial 2 - Theme</a></li>
<li><a href="Top50-Ggplot2-Visualizations-MasterList-R-Code.html">ggplot2 Tutorial 3 - Masterlist</a></li>
<li><a href="ggplot2-cheatsheet.html">ggplot2 Quickref</a></li>
<li class="dropdown-header">Foundations</li>
<li><a href="Linear-Regression.html">Linear Regression</a></li>
<li><a href="Statistical-Tests-in-R.html">Statistical Tests</a></li>
<li><a href="Missing-Value-Treatment-With-R.html">Missing Value Treatment</a></li>
<li><a href="Outlier-Treatment-With-R.html">Outlier Analysis</a></li>
<li><a href="Variable-Selection-and-Importance-With-R.html">Feature Selection</a></li>
<li><a href="Model-Selection-in-R.html">Model Selection</a></li>
<li><a href="Logistic-Regression-With-R.html">Logistic Regression</a></li>
<li><a href="Environments.html">Advanced Linear Regression</a></li>
<li class="dropdown-header">Advanced Regression Models</li>
<li><a href="adv-regression-models.html">Advanced Regression Models</a></li>
<li class="dropdown-header">Time Series</li>
<li><a href="Time-Series-Analysis-With-R.html">Time Series Analysis</a></li>
<li><a href="Time-Series-Forecasting-With-R.html">Time Series Forecasting </a></li>
<li><a href="Time-Series-Forecasting-With-R-part2.html">More Time Series Forecasting</a></li>
<li class="dropdown-header">High Performance Computing</li>
<li><a href="Parallel-Computing-With-R.html">Parallel computing</a></li>
<li><a href="Strategies-To-Improve-And-Speedup-R-Code.html">Strategies to Speedup R code</a></li>
<li class="dropdown-header">Useful Techniques</li>
<li><a href="Association-Mining-With-R.html">Association Mining</a></li>
<li><a href="Multi-Dimensional-Scaling-With-R.html">Multi Dimensional Scaling</a></li>
<li><a href="Profiling.html">Optimization</a></li>
<li><a href="Information-Value-With-R.html">InformationValue package</a></li>
</ul>
</li>
</ul>
-->
<div class="site-header" style="display:flex; justify-content:space-between; align-items:center; padding: 12px 0 8px 0; flex-wrap: nowrap; gap: 10px;">
<div style="display:flex; align-items:center; gap:8px; min-width:0;">
<button id="mobile-menu-btn" aria-label="Menu" style="display:none;background:none;border:1px solid #d0d7de;border-radius:6px;padding:4px 8px;cursor:pointer;font-size:18px;line-height:1;color:#666;">☰</button>
<h3 style="margin:0;white-space:nowrap;"><a href="/" style="text-decoration:none;">r‑statistics.co</a><small style="color:#999; margin-left:4px; font-size:11px;"> by Selva Prabhakaran</small></h3>
</div>
<div style="display:flex; align-items:center; gap:12px; flex-shrink:0;">
<a href="/about/" style="font-size:13px; color:#666; text-decoration:none;">About</a>
<button id="dark-mode-toggle" aria-label="Toggle dark mode" title="Toggle dark mode"
style="background:none;border:1px solid #d0d7de;border-radius:6px;padding:4px 8px;cursor:pointer;font-size:16px;line-height:1;color:#666;transition:all 0.2s;">
☽
</button>
<form onsubmit="my_search_google(); return false;" style="margin:0;">
<input type="text" class="form-control" id="my-google-search" placeholder="Search.." style="width:130px; height:30px; font-size:12px; border-radius:6px;">
</form>
</div>
</div>
<hr style="margin:0 0 16px 0;">
</div>
<div class="row">
<div class="col-xs-12 col-sm-3" id="nav">
<div id="sidebar-nav">
<!-- Loaded dynamically from www/sidebar.json by toc.js -->
</div>
</div>
<div id="content" class="col-xs-12 col-sm-7">
<nav class="breadcrumb-nav" aria-label="Breadcrumb"><a href="/">Home</a> <span class="breadcrumb-sep">›</span> <span>Learn R</span> <span class="breadcrumb-sep">›</span> <span class="breadcrumb-current">Install R & RStudio in 2026: The Setup That Actually Works First Time</span></nav>
<h1>Install R & RStudio in 2026: The Setup That Actually Works First Time</h1>
<p class="lead">To use R, you install two things: R itself (the language engine) and RStudio (the editor you'll actually work in). R does the computing; RStudio makes it comfortable. Both are free and take about 5 minutes total.</p>
<p>Most installation guides show you where to click but skip the settings that save you hours later. This guide covers the full setup — installation, verification, first-run settings, and the most common errors with their fixes — for Windows, Mac, and Linux.</p>
<h2>Introduction</h2>
<p><strong>R</strong> is the programming language — the engine that runs your code. <strong>RStudio</strong> is an IDE (Integrated Development Environment) — the dashboard where you write, run, and debug that code. You need both, and you must install R first because RStudio depends on it.</p>
<p>Think of it like this: R is the car engine, RStudio is the cockpit with the steering wheel, dashboard, and GPS. You wouldn't drive an engine without a cockpit — and you wouldn't use R without RStudio.</p>
<p>Here's the plan:</p>
<ol>
<li>Install R (the engine)</li>
<li>Install RStudio (the cockpit)</li>
<li>Verify everything works</li>
<li>Configure first-run settings</li>
<li>Install your first package</li>
</ol>
<p>By the end, you'll have a fully working R development environment and will have run your first R code.</p>
<h2>Prerequisites</h2>
<p>Before installing, make sure your system meets these minimum requirements:</p>
<table class="table table-striped">
<thead>
<tr><th>Requirement</th><th>Windows</th><th>Mac</th><th>Linux (Ubuntu)</th></tr>
</thead>
<tbody>
<tr><td>OS version</td><td>Windows 10+</td><td>macOS 12 (Monterey)+</td><td>Ubuntu 20.04+</td></tr>
<tr><td>Disk space</td><td>~500 MB (R) + ~500 MB (RStudio)</td><td>~500 MB + ~500 MB</td><td>~500 MB + ~500 MB</td></tr>
<tr><td>RAM</td><td>4 GB minimum, 8 GB recommended</td><td>4 GB minimum, 8 GB recommended</td><td>4 GB minimum, 8 GB recommended</td></tr>
<tr><td>Admin rights</td><td>Yes (for installation)</td><td>Yes (password required)</td><td>Yes (sudo access)</td></tr>
</tbody>
</table>
<blockquote><p><strong>Already have R installed?</strong> If you have an older version, you can install the new version alongside it. The installer won't break your existing setup. After installing, RStudio will automatically use the newest version.</p></blockquote>
<h2>Step 1: Install R</h2>
<p>R is distributed through <strong>CRAN</strong> (the Comprehensive R Archive Network). Here's how to install it on each operating system.</p>
<h4>Windows</h4>
<ol>
<li>Go to the CRAN download page: <strong>https://cran.r-project.org/</strong></li>
<li>Click <strong>"Download R for Windows"</strong></li>
<li>Click <strong>"base"</strong> (this is the standard installation)</li>
<li>Click <strong>"Download R-4.x.x for Windows"</strong> (the version number will be the latest)</li>
<li>Run the downloaded <code>.exe</code> file</li>
<li>In the installer wizard:
<ul>
<li>Accept the default installation directory (<code>C:\Program Files\R\R-4.x.x</code>)</li>
<li>Accept the default components (all checked)</li>
<li>Choose <strong>"No"</strong> when asked about customizing startup options (the defaults are fine)</li>
<li>Click <strong>"Next"</strong> through the remaining screens and <strong>"Finish"</strong></li>
</ul>
</li>
</ol>
<p><strong>That's it.</strong> R is now installed. You'll see an "R" icon in your Start Menu, but you won't use it directly — you'll use RStudio instead.</p>
<h4>Mac</h4>
<ol>
<li>Go to <strong>https://cran.r-project.org/</strong></li>
<li>Click <strong>"Download R for macOS"</strong></li>
<li>Under "Latest release:", click the <code>.pkg</code> file that matches your Mac:
<ul>
<li><strong>Apple Silicon (M1/M2/M3/M4):</strong> Download the <code>arm64</code> version</li>
<li><strong>Intel Mac:</strong> Download the <code>x86_64</code> version</li>
<li>Not sure which you have? Click the Apple menu → <strong>"About This Mac"</strong> → look for "Chip" (Apple M-series) or "Processor" (Intel)</li>
</ul>
</li>
<li>Open the downloaded <code>.pkg</code> file</li>
<li>Follow the installation wizard — you'll need to enter your Mac password</li>
<li>Click <strong>"Install"</strong> and then <strong>"Close"</strong> when finished</li>
</ol>
<h4>Linux (Ubuntu/Debian)</h4>
<p>Open a terminal and run these commands:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"># Update package list
sudo apt update
# Install R
sudo apt install r-base r-base-dev -y
# Verify installation
R --version</code></pre></div>
<p>For the <strong>latest R version</strong> (Ubuntu's default repos may be a version behind), add the official CRAN repository first:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"># Add the CRAN GPG key
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# Add the CRAN repository (replace "jammy" with your Ubuntu release codename)
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
# Update and install
sudo apt update
sudo apt install r-base r-base-dev -y</code></pre></div>
<h2>Step 2: Install RStudio</h2>
<p>Now that R is installed, install RStudio — the IDE you'll actually use every day.</p>
<h4>Windows</h4>
<ol>
<li>Go to <strong>https://posit.co/download/rstudio-desktop/</strong></li>
<li>The page auto-detects your OS. Click the big blue <strong>"Download RStudio"</strong> button</li>
<li>Run the downloaded <code>.exe</code> file</li>
<li>Accept all defaults in the installer — click <strong>"Next"</strong> through everything and <strong>"Finish"</strong></li>
<li>Open RStudio from the Start Menu</li>
</ol>
<h4>Mac</h4>
<ol>
<li>Go to <strong>https://posit.co/download/rstudio-desktop/</strong></li>
<li>Click <strong>"Download RStudio"</strong> — it'll download a <code>.dmg</code> file</li>
<li>Open the <code>.dmg</code> file</li>
<li>Drag the <strong>RStudio icon</strong> into the <strong>Applications</strong> folder</li>
<li>Open RStudio from the Applications folder or Launchpad</li>
</ol>
<blockquote><p><strong>Mac security warning:</strong> If you get a "cannot be opened because the developer cannot be verified" message, go to <strong>System Preferences → Privacy & Security</strong> and click <strong>"Open Anyway"</strong> next to the RStudio message.</p></blockquote>
<h4>Linux (Ubuntu/Debian)</h4>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"># Download the latest .deb package (check posit.co for the current URL)
wget https://download1.rstudio.org/electron/jammy/amd64/rstudio-2024.12.1-563-amd64.deb
# Install it
sudo dpkg -i rstudio-*.deb
# Fix any missing dependencies
sudo apt install -f -y</code></pre></div>
<p>Then open RStudio from your application menu.</p>
<h2>Step 3: Verify It Works</h2>
<p>Open RStudio. You should see four panels:</p>
<ol>
<li><strong>Console</strong> (bottom-left) — where R code runs</li>
<li><strong>Source</strong> (top-left) — where you write scripts (may be hidden until you open a file)</li>
<li><strong>Environment</strong> (top-right) — shows your variables and data</li>
<li><strong>Files/Plots/Help</strong> (bottom-right) — file browser, plot viewer, help docs</li>
</ol>
<p>If you see these panels, RStudio found R automatically. Let's verify by running code.</p>
<p>Click in the <strong>Console</strong> panel (bottom-left), type <code>R.version.string</code>, and press <strong>Enter</strong>. You should see something like: <code>"R version 4.4.2 (2024-10-31)"</code>. If you see a version number, R is installed correctly.</p>
<p>Now try this longer test — you can run it right here in your browser to see what the output should look like, then compare it with what you get in your local RStudio:</p>
<div class="webr-container">
<div class="webr-code-block">
<div class="webr-editor" data-language="r"># Test 1: Basic math
cat("2 + 2 =", 2 + 2, "\n")
# Test 2: Create a variable
my_name <- "R Learner"
cat("Hello,", my_name, "! R is working.\n")
# Test 3: Built-in dataset
cat("mtcars has", nrow(mtcars), "rows and", ncol(mtcars), "columns\n")
# Test 4: Basic statistics
cat("Average MPG of cars:", round(mean(mtcars$mpg), 1), "\n")
# Test 5: Your R version
cat("R version:", R.version.string, "\n")</div>
<div class="webr-buttons">
<button class="btn btn-sm btn-primary webr-run-btn" onclick="runWebR(this)">▶ Run</button>
<button class="btn btn-sm btn-default webr-reset-btn" onclick="resetWebR(this)">↺ Reset</button>
</div>
<pre class="webr-output"></pre>
</div>
</div>
<p>If all five tests print output without errors, your installation is perfect. Click <strong>Run</strong> above to see the expected output, then try the same code in your local RStudio console.</p>
<h2>Step 4: First Settings to Change</h2>
<p>RStudio's default settings are mostly fine, but there are three changes that will save you headaches later. Go to <strong>Tools → Global Options</strong> in RStudio:</p>
<h4>4.1. Turn Off Workspace Saving</h4>
<p>Go to <strong>General → Basic</strong> and change these:</p>
<ul>
<li><strong>"Restore .RData into workspace at startup"</strong> → Uncheck this</li>
<li><strong>"Save workspace to .RData on exit"</strong> → Set to <strong>"Never"</strong></li>
</ul>
<p><strong>Why?</strong> Old variables lingering from previous sessions cause hard-to-find bugs. You want every session to start clean. If you need data to persist, save it explicitly with <code>saveRDS()</code>.</p>
<h4>4.2. Set Your CRAN Mirror</h4>
<p>Go to <strong>Packages</strong> and click <strong>"Change"</strong> next to the CRAN mirror. Choose a mirror close to your location:</p>
<ul>
<li><strong>US:</strong> any US mirror, or "0-Cloud" (which auto-selects the closest)</li>
<li><strong>Europe:</strong> your country's mirror</li>
<li><strong>Asia:</strong> Japan or Australia mirrors tend to be fast</li>
</ul>
<p>This controls where R downloads packages from. A closer mirror means faster downloads.</p>
<h4>4.3. Pick a Theme (Optional but Nice)</h4>
<p>Go to <strong>Appearance</strong> and try different <strong>Editor themes</strong>. Popular choices:</p>
<ul>
<li><strong>Tomorrow Night</strong> — dark theme, easy on the eyes</li>
<li><strong>Solarized Dark</strong> — warm tones, popular with developers</li>
<li><strong>Textmate</strong> — classic light theme</li>
</ul>
<p>Also increase the <strong>font size</strong> if the default (10pt) feels small. Most people settle on 12-14pt.</p>
<h2>Step 5: Install Your First Package</h2>
<p>Packages extend R's capabilities. The tidyverse is the most important collection of packages for data science — let's install it to verify your package system works.</p>
<p>In RStudio's Console, type:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">install.packages("tidyverse")</code></pre></div>
<p>This will take 1-3 minutes (it downloads and compiles several packages). You'll see lots of text scrolling — that's normal. When you see the <code>></code> prompt again, it's done.</p>
<p>Now verify it works. You can run this code in your local RStudio — or try it here first to see the expected output:</p>
<div class="webr-container">
<div class="webr-code-block">
<div class="webr-editor" data-language="r"># Load the tidyverse
library(dplyr)
library(ggplot2)
# Quick data manipulation
mtcars |>
group_by(cyl) |>
summarise(avg_mpg = round(mean(mpg), 1))</div>
<div class="webr-buttons">
<button class="btn btn-sm btn-primary webr-run-btn" onclick="runWebR(this)">▶ Run</button>
<button class="btn btn-sm btn-default webr-reset-btn" onclick="resetWebR(this)">↺ Reset</button>
</div>
<pre class="webr-output"></pre>
</div>
</div>
<p>If you see a table with average MPG grouped by cylinder count, your package installation is working perfectly.</p>
<p>Now try creating a plot:</p>
<div class="webr-container">
<div class="webr-code-block">
<div class="webr-editor" data-language="r">library(ggplot2)
# Your first ggplot2 visualization
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point(color = "steelblue", size = 3) +
geom_smooth(method = "lm", se = TRUE, color = "tomato") +
labs(title = "Your First R Plot!",
subtitle = "Car weight vs fuel efficiency",
x = "Weight (1000 lbs)",
y = "Miles per Gallon") +
theme_minimal()</div>
<div class="webr-buttons">
<button class="btn btn-sm btn-primary webr-run-btn" onclick="runWebR(this)">▶ Run</button>
<button class="btn btn-sm btn-default webr-reset-btn" onclick="resetWebR(this)">↺ Reset</button>
</div>
<pre class="webr-output"></pre>
</div>
</div>
<p>In your local RStudio, this plot will appear in the <strong>Plots</strong> panel (bottom-right). Click <strong>"Export"</strong> to save it as an image. Congratulations — you just created a publication-quality visualization.</p>
<h2>Common Installation Errors (and How to Fix Them)</h2>
<h4>"R is not recognized as a command"</h4>
<p><strong>Problem:</strong> You installed R but the terminal can't find it.</p>
<p><strong>Fix (Windows):</strong> Add R to your PATH. Search for "Environment Variables" in Windows Settings, edit the PATH variable, and add <code>C:\Program Files\R\R-4.x.x\bin</code>. Or simply use RStudio — it finds R automatically.</p>
<p><strong>Fix (Mac/Linux):</strong> Run <code>which R</code> in the terminal. If nothing shows, R didn't install to the expected location. Reinstall using the steps above.</p>
<h4>"RStudio: Unable to locate R"</h4>
<p><strong>Problem:</strong> RStudio can't find your R installation.</p>
<p><strong>Fix:</strong> RStudio looks for R in standard locations. If you installed R to a custom path, tell RStudio where to find it: <strong>Tools → Global Options → General → R version → Change</strong> and browse to your R installation.</p>
<h4>"Package installation failed: non-zero exit status"</h4>
<p><strong>Problem:</strong> A package failed to compile from source.</p>
<p><strong>Fix (Windows):</strong> Install <strong>Rtools</strong> from https://cran.r-project.org/bin/windows/Rtools/. Rtools provides the compiler that some packages need.</p>
<p><strong>Fix (Mac):</strong> Install Xcode Command Line Tools: open Terminal and run <code>xcode-select --install</code>.</p>
<p><strong>Fix (Linux):</strong> Install development libraries: <code>sudo apt install build-essential libcurl4-openssl-dev libssl-dev libxml2-dev</code>.</p>
<h4>"Warning: package was built under R version X.X.X"</h4>
<p><strong>Problem:</strong> A package was built for a different R version.</p>
<p><strong>Fix:</strong> This is usually just a warning, not an error. The package will still work. To get rid of it, update the package: <code>install.packages("package_name")</code>.</p>
<h4>"Cannot open connection" or "cannot open URL"</h4>
<p><strong>Problem:</strong> R can't reach the internet to download packages.</p>
<p><strong>Fix:</strong> Check your internet connection. If you're behind a corporate firewall or VPN, try changing your CRAN mirror: <code>options(repos = "https://cloud.r-project.org/")</code> then retry the install.</p>
<h4>Permission denied errors (Linux)</h4>
<p><strong>Problem:</strong> You can't install packages to the system library.</p>
<p><strong>Fix:</strong> Don't use <code>sudo</code> for package installation. Instead, R will ask to create a personal library — say <strong>"yes"</strong>. Packages will install to <code>~/R/</code> and work fine.</p>
<h2>Alternative: Positron IDE</h2>
<p>In 2025, Posit (the company behind RStudio) released <strong>Positron</strong> — a new IDE built on VS Code's architecture. It supports both R and Python in one editor.</p>
<p><strong>Should you use Positron instead of RStudio?</strong></p>
<ul>
<li>If you're a <strong>beginner</strong> → stick with <strong>RStudio</strong>. It's more mature, better documented, and all R tutorials assume you're using it.</li>
<li>If you're <strong>experienced</strong> and already use VS Code → try <strong>Positron</strong>. It feels familiar and handles polyglot (R + Python) workflows well.</li>
<li>If you just want to <strong>get started fast</strong> → <strong>RStudio</strong> is the safe choice.</li>
</ul>
<p>We cover Positron vs RStudio in detail in a later tutorial. For now, RStudio is the recommended starting point.</p>
<h2>Summary</h2>
<p>Here's your complete setup checklist:</p>
<table class="table table-striped">
<thead>
<tr><th>Step</th><th>What to Do</th><th>Time</th></tr>
</thead>
<tbody>
<tr><td>1. Install R</td><td>Download from cran.r-project.org, run installer</td><td>2 min</td></tr>
<tr><td>2. Install RStudio</td><td>Download from posit.co/download, run installer</td><td>2 min</td></tr>
<tr><td>3. Open RStudio</td><td>Verify 4-panel layout, run <code>R.version.string</code></td><td>1 min</td></tr>
<tr><td>4. Change settings</td><td>Turn off workspace save, set CRAN mirror</td><td>2 min</td></tr>
<tr><td>5. Install tidyverse</td><td>Run <code>install.packages("tidyverse")</code> in Console</td><td>2-3 min</td></tr>
<tr><td>6. Verify</td><td>Run <code>library(dplyr)</code> and <code>library(ggplot2)</code> — no errors</td><td>30 sec</td></tr>
</tbody>
</table>
<p><strong>Total time: ~10 minutes.</strong> You're ready to start coding in R.</p>
<h2>FAQ</h2>
<h4>Do I need to install R if I only want RStudio?</h4>
<p>Yes. RStudio is just an editor — it doesn't include R itself. You must install R first (from CRAN), then install RStudio. RStudio will automatically detect and use your R installation.</p>
<h4>Can I have multiple versions of R installed?</h4>