The combo of the open-source statistical analysis software R and the companion commercial software RStudio Desktop is increasingly being used in industry and in the Kellogg curriculum. To get up and running with this powerful system, you can follow our guidance below.
Contents
To download, go to the product page for RStudio Desktop, click Download RStudio Desktop. On the Choose Your Version page, click Download under the RStudio Desktop Open Source License column. This should autodetect your operating system (Windows or Mac) and give you the right installer for your computer. If it doesn’t, you can choose the correct installer for your respective OS under All Installers.
After the installer is downloaded, run it and accept all defaults.
In addition to using built-in R functionality, it is likely you will need additional R packages. This can easily be done by typing the following into the RStudio console: install.packages('package'), where ‘package’ is the package name in quotations.
After installing the package, you need to tell R that you will be using the package by typing in: library(package) in your file, where package is the package name. Note you only need to perform the installation command install.packages('package') once, but you need to call library(package) every time you restart R and want to use that package.
You’ll likely be doing your coursework in RMarkdown, a document composition language that lets you combine your R code, its text and graphical output, and your expository text all in one text-based file. This can be converted into PDF in RStudio using the TinyTeX package, which will then allow you to portably share your document for homework submission and collaboration.
To install TinyTeX:
In the console, enter the appropriate commands for your operating system:
Windows: Enter these two commands, pressing Enter after each.
install.packages('tinytex')
tinytex::install_tinytex(force = TRUE, repository = 'http://mirror.mwt.me/ctan/systems/texlive/tlnet')
Mac OS: Enter these two commands, pressing Enter after each:
install.packages('tinytex')
tinytex::install_tinytex(force = TRUE, dir='~/.TinyTex', repository = 'http://mirror.mwt.me/ctan/systems/texlive/tlnet') # That's a tilde, not a dash
TinyTeX installed to C:\Users\John Smith\AppData\Roaming/TinyTeX
Please restart your R session and IDE (if you are using one, such as RStudio or Emacs) and check if tinytex:::is_tinytex() is TRUE.
tinytex:::is_tinytex()The output should be TRUE. If so, continue to the next section. If not, please contact us and send a screenshot of your console.
The following are free online resources for getting started with and mastering R. They are roughly sorted from introductory to expert.
There are a few places where installation can run into issues. These are largely platform-specific.
The most common issue on Windows is that packages fail to import after installation if your Documents folder is synced with OneDrive. This happens because R stores packages in the Documents folder, and OneDrive interferes.
This is fixed by setting the R_LIBS_USER environment variable to a folder that is not synced by OneDrive.
This can be done by running this script or by following these steps:
rundll32 sysdm.cpl,EditEnvironmentVariables and hit OK.R_LIBS_USERC:\Users\username\R)Now that you changed your library directory, you’ll need to reinstall your libraries.
By and large, the most common issue on the Mac shows up with the following error code at the end of the TinyTeX installation:
`add_link_dir_dir: destination /usr/local/bin not writable, no links from /Users/username/Library/TinyTeX/bin/x86_64-darwin. add of symlinks had 1 error(s), see messages above. add of symlinks had 1 error(s), see messages above. tlmgr: An error has occurred. See above messages. Exiting.`
You can fix this by doing the following:
, repository = 'http://mirror.mwt.me/ctan/systems/texlive/tlnet')