Installing R and RStudio (2024)

R and RStudio are both free,open-source software, available for all commonly usedoperating systems. R is developed cooperatively andnoncommercially under the auspices of the Free SoftwareFoundation; RStudio is a commercial product.

R and RStudio install in the standardmanner on each of Windows, macOS, and Linux systems.System-specific instructions for installing R are given below.Regardless of your operating system, you should install R beforeinstalling RStudio.

Please read and follow theseinstructions carefully. Installation assistance will also beavailabile from the instructor (John Fox) and teachingassistant (Allison Leanage) prior to the start of the lectureseries and during office hours.

Installing R on Windows

Installing R and RStudio (1)Visit the Comprehensive R ArchiveNetwork (CRAN) and select a mirror site; a list of CRAN mirrorsappears at the upper left of the CRAN home page. I suggestthat you use the 0-Cloudmirror, which is the first on the list. Click on thelink Download R for Windows, which appears nearthe top of the page; then click on install R for thefirst time, and subsequently on Download R x.y.zfor Windows (where x.y.z is the current version of R,which is R 4.1.0 at the start of the lectures series). Onceit is downloaded, double-click on the R installer. Youmay take all of the defaults, but I suggest that youmake the following modifications:

Installing R and RStudio (2)Instead of installing R in thestandard location, C:\Program Files\R\R-x.y.z, I suggest thatyou use C:\R\R-x.y.z. Again, x.y.z is the current version ofR. This will allow you to install packages in the main Rlibrary without running R with administrator privileges andmay avoid problems that sometimes occur when there are spacesin paths.

Installing R and RStudio (3)You may take all of theremaining defaults in the R for Windows installer.

Building Packages Under Windows, etc.(Optional)

Installing R and RStudio (4)If you wish to build packages, oruse compiled C, C++, or Fortran code in R, or use the rstanpackage for Bayesian inference, you will have to installsome additional software and properly configure your Windowssystem. You do not have to be able to build R packagesin order to install pre-built Windows binary packages fromCRAN, so these steps are generally unnecessary unlessyou plan to write your own packages, use compiled code, oruse rstan. None of these topics are covered in thelecture series.

Installing R and RStudio (5)Click on the Rtools link onthe R for Windows CRAN page. Download the currentversion of the Rtools installer and run it. You may take allof the other defaults. An additional necessary step is to addthe Rtools usr\bin subdirectory to your system path; forexample, if Rtools is installed in c:\rtoolsxy (which is thestandard location for version xy of Rtools), then you wouldadd c:\rtoolsxy\usr\bin; to your system path. Type thislocation carefully, including the terminating semicolon -- youdon't want to mess up your path.

An alternative, and possibly safer,procedure for specifying the path to Rtools is described onthe Rtoolswebpage.

If you want to be able to build Rpackages outside of RStudio, also add c:\R\R-x.y.z\bin; to thepath (assuming that you installed R in the location that Isuggested).

Installing R and RStudio (6)If you want to be able to build PDFhelp files for packages, download and install the MiKTeX LaTeX system; there isalso a link to MiKTeX on the Building R for Windowspage. Installing MiKTeX will also allow you to create Sweaveand knitr LaTeX documents in RStudio, and to compile RMarkdown documents directly to PDF files.

Installing R on macOS

Installing R and RStudio (7)Visit the Comprehensive R ArchiveNetwork (CRAN) and select a mirror site; a list of CRAN mirrorsappears at the upper left of the CRAN home page. I suggestthat you use the 0-Cloudmirror, which is the first on the list. Click on thelink Download R for MacOS X, which appears nearthe top of the page; then click on R-x.y.z.pkg(where x.y.z is the current version of R -- R 4.1.0 at thestart of the lectures series), which assumes that you areusing macOS 10.11 (El Capitan) or higher. You'll also findolder versions of R if you have an older version of macOS.Note: As a general matter, you're probably better offupdating your macOS to the current version.

Installing R and RStudio (8)Two macOS installers are provided for thecurrent version of R: one for Macs that use Intel chips andone for newer Macs that use the Apple M1 chip. The formerinstaller is named R-x.y.z.pkgand the latter is named R-x.y.z-arm64.pkg. Atpresent, I recommend that you use the R-x.y.z.pkg installer whetheror not you have a Mac with an Intel chip. The Intelversion will work with both kinds of Macs, and there arestill some compatibility issues for certain packagesassociated with the M1-specific version of R.

Installing R and RStudio (9)Once it is downloaded,double-click on the R installer. You may take all of thedefaults.

Building Packages Under macOS, etc.(Optional)

Installing R and RStudio (10)If you wish to build packages, oruse compiled C, C++, or Fortran code in R, or use the rstanpackage for Bayesian inference, you must install the AppleXcode developer tools. None of these topics is covered inthe lecture series. For macOS 10.7 (Lion) or higher, you caninstall Xcode for free from the App Store. For earlierversions of macOS, Xcode can be installed from your systemDVD or downloaded from the Apple developer website. Youdo not need Xcode to install pre-built macOS binarypackages from CRAN, so this step is unnecessaryunless you plan to write your own packages, use compiledcode, or use the rstan Bayesianestimation package.

Installing R and RStudio (11)Some R packages include Fortran, C,or C++ code; to build such packages, you will have to installcompilers for these languages.The C and C++ compilers areincluded in the Apple Xcode tools, but you will have toseparately downloadand install a Fortran compiler.

Installing R and RStudio (12)If you want to be able to build PDFhelp files, download and install the MacTeX LaTeX system.Installing MacTeX will also allow you to create Sweave andknitr LaTeX documents in RStudio, and to compile R Markdowndocuments directly to PDF files.

Installing X-Windows on macOS(Optional)

Installing R and RStudio (13)Some R software (e.g., my Rcmdrpackage) makes use of the Tcl/Tk graphical-user-interface(GUI) builder via the tcltk package tocreate point-and-click interfaces and to display GUIelements such as progress bars. To use the tcltkpackage, which is a standard part of the R distribution, youmust have the X11 windowing system installed on your Mac.Some other packages that don't use Tcl/Tk, such as the rglpackage for dynamic 3D graphics, also require X11.

Installing R and RStudio (14)Check to see whether the X11windowing system (X Windows) has already been installed onyour computer. If you wish, it should do no harm to skipthis step and simply go to the next step to install XQuartz.

ForOS X 10.6 and 10.7,the file X11.app should appearin the Utilities folderunder Applications in the finder. This application shouldalways be installed under OS X 10.7.

ForOS X 10.8orhigher, the file is named XQuartz.app and is no longerincluded with the operating system. XQuartz.app may also beinstalled in OS X 10.6 or 10.7.

Note that if you upgrade macOS, youwill have to reinstall XQuartz even if you installed itpreviously.

You may also issue the command capabilities("X11")at the R command prompt. If the response is TRUE thenX11 is installed.

Installing R and RStudio (15)If neither X11.app nor XQuartz.app isinstalled, install XQuartz from https://www.xquartz.org/.As mentioned, it should do no harm to install XQuartzeven if you have X11 currently installed.

      1. Download the disk image(dmg) file for XQuartz.

      2. When you open this file bydouble-clicking on it, you'll find XQuartz.pkg;double-click on it to run the installer, clickingthrough all the defaults.

      3. Important:After the installer runs, you'll have to logout and back on to your macOS account, orjust reboot your Mac. Also, onfirst use, XQuartz builds a cache of fonts and soinitial performance may be slow; this problem should goaway after a short period of time.

Installing R on Linux Systems

Installing R and RStudio (16)Visit the Comprehensive R ArchiveNetwork (CRAN) and select a mirror site near you; alist of CRANmirrors appears at the upper left of the CRAN homepage. I suggest that you use the 0-Cloud mirror,which is the first on the list. Click on the link DownloadR for Linux, which appears near the top of the page.R is available for several Linux distributions (Debian,RedHat, SUSE, and Ubuntu); select your distribution, andproceed as directed.

Installing R and RStudio (17)If you have a Linux or Unix systemthat's not compatible with one of these distributions, youwill have to compile R from source code; the procedurefor doing so is described in the R FAQ (frequently askedquestions) list.

Installing RStudio

Installing R and RStudio (18)Go to the RStudiodownload page, select the free version of RStudioDesktop, click the Download button, and click on thelink to the appropriate installer for your operating system(Windows, macOS, or Linux distro). Visit the RStudio IDEhome page for more information about RStudio.

Installing R and RStudio (19)Once it is downloaded, run theRStudio installer and take all of the defaults: In Windows,double-click on the RStudio installer to start theinstallation; in macOS, double-click on the downloaded RStudiodisk-image file, and drag the RStudio icon to the Applicationsfolder.

Installing R and RStudio (20)When you first run RStudio, it shoulddetect your R installation and start the R console. Toconfigure RStudio to your taste, select Tools > GlobalOptions (Windows) or RStudio > Preferences(macOS) from the RStudio menus. Inparticular, I suggest that on the General optionsscreen you deselect Restore .RDatainto workspace at startup, and set Saveworkspace to .RData on exit to Never.

Installing R and RStudio (21)If you encounter difficulties,consult the RStudiotroubleshooting guide. or seek help from John orAllison.

Installing R Packages for the LectureSeries

Installing R and RStudio (22)Once you have installed R andRStudio, you can install additional packages required forthe lecture series by typing the following command at the> command prompt in the R Console (and pressing the Enteror return key):

install.packages(c("car","data.table", "effects", "knitr", "lme4", "rgl", "rmarkdown","sfsmisc", "tidyverse"))

You can simply copy and paste thiscommand from these installation instructions. Alternatively,you can install packages from the RStudio Packagestab. Be aware that, depending on the speed of your internetconnection, it may take some time to download and installthese packages and their dependencies.

Installing R and RStudio (23) If you want to tryusing C++ code within R (not discussed in the lecture series),also install the Rcpp package, install.packages("Rcpp").You'll also have to install a C++ compiler, as described inthe sections above on building packages under Windows andmacOS.

Installing R and RStudio (24) Similarly, if you want to use theStan Bayesian statistical software via the rstanpackage (not discussed in the lecture series), you'll have toinstall the package by the command install.packages("rstan"), andalso install a C++ compiler.

Installing R and RStudio (2024)
Top Articles
We all change (Percy Jackson fanfic) - Chapter I
Pertemis - ReaderOfTheSword - Wattpad
Finance Minor Osu
Nambe Flatware Discontinued
FTC challenge of biggest grocery deal ever captures Albertsons exec's surprise: 'You are basically creating a monopoly in grocery with the merger'
Whispering Oaks In Battle Creek Michigan
Weekends Only Credit Card Login
Christine Paduch Howell Nj
Morristown Daily Record Obituary
1998 Pontiac Firebird Trans Am for sale - Denver, CO - craigslist
Onlinewagestatements Lifepoint
Holiday Gift Bearer In Egypt
Metv Plus Schedule Today Near Texas
8636643427
Edgenuity Spanish 1 Semester 1 Final Exam Answers
My Compeat Workforce
Flavor Of India Hayward
Amrn Investors Hub
Walmart Supercenter Nearest To My Location
Talecris New Donor Fees
Caro Walmart Hair Salon
English - Þjóðleikhúsið
Seo Glossary definition page
Technische Informatica | Studeren bij hogeschool Saxion | Hogeschool Saxion
Lake Compounce Family 4 Pack
Soap2Day That 70S Show
Yankee Candle Store Locator
3Si Tracker Login
International Medical Insurance for Employers from Aetna - Global Health Plans for Expatriates & Business Travel Employees | Aetna
Txdot Average Unit Prices
Federal Express Drop Off Center Near Me
Lawson Uhs
Humbled And Subjugated Breeding Machine
Standard Bank Learnership Programme 2021
Licorice Pizza 123Movies
Ric Flair's Net Worth (Updated 2023) | Inspirationfeed
Milwaukee Nickname Crossword Clue
Dresses Walmart
Ben 10 Wikia
Ups Locations Massachusetts
Susan Miller Libra 2023 Predictions
Arknights Gamepress
Straightup Internet Hotspot Pass
DETERMINING USER RESPONSE TO NOTIFICATIONS BASED ON A PHYSIOLOGICAL PARAMETER专利检索- ...使用诱导响应的专利检索查询-专利查询网
R. Kelly trial: A look at the key moments after star found guilty
Coffey Leaked
Safe Pet Adoption Tips For Craigslist | The VetHaven
R/Mcoc
Pamela Dunlap Motorcycle Accident
Parc Soleil Drowning
Latest Posts
Article information

Author: Barbera Armstrong

Last Updated:

Views: 5877

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Barbera Armstrong

Birthday: 1992-09-12

Address: Suite 993 99852 Daugherty Causeway, Ritchiehaven, VT 49630

Phone: +5026838435397

Job: National Engineer

Hobby: Listening to music, Board games, Photography, Ice skating, LARPing, Kite flying, Rugby

Introduction: My name is Barbera Armstrong, I am a lovely, delightful, cooperative, funny, enchanting, vivacious, tender person who loves writing and wants to share my knowledge and understanding with you.