A Installing R
Installing R and RStudio is usually straightforward. The sections below explain how and there is a helpful YouTube video here.
A.1 Installing Base R
Install base R. Choose the download link for your operating system (Linux, Mac OS X, or Windows).
If you have a Mac, install the latest release from the newest R-x.x.x.pkg
link (or a legacy version if you have an older operating system). After you install R, you should also install XQuartz to be able to use some visualisation packages.
If you are installing the Windows version, choose the "base" subdirectory and click on the download link at the top of the page. After you install R, you should also install RTools; use the "recommended" version highlighted near the top of the list.
If you are using Linux, choose your specific operating system and follow the installation instructions.
A.2 Installing RStudio
Go to rstudio.com and download the RStudio Desktop (Open Source License) version for your operating system under the list titled Installers for Supported Platforms.
A.3 RStudio Settings
There are a few settings you should fix immediately after updating RStudio. Go to Global Options...
under the Tools
menu (⌘,), and in the General tab, uncheck the box that says Restore .RData into workspace at startup
. If you keep things around in your workspace, things will get messy, and unexpected things will happen. You should always start with a clear workspace. This also means that you never want to save your workspace when you exit, so set this to Never
. The only thing you want to save are your scripts.
You may also want to change the appearance of your code. Different fonts and themes can sometimes help with visual difficulties or dyslexia.
You may also want to change the settings in the Code tab. Foe example, Lisa prefers two spaces instead of tabs for my code and likes to be able to see the whitespace characters. But these are all a matter of personal preference.
A.4 Installing LaTeX
You can install the LaTeX typesetting system to produce PDF reports from RStudio. Without this additional installation, you will be able to produce reports in HTML but not PDF. This course will not require you to make PDFs. To generate PDF reports, you will additionally need to install tinytex
(Xie, 2022) and run the following code:
tinytex::install_tinytex()
A.5 Installing the brms
package
In chapter 10, you will use the brms
to fit Bayesian regression models. Behind the scenes, this package uses a programming language called Stan which requires a C++ compiler. Unlike other packages, you cannot just use the install.packages()
function to install it, there are a few steps to follow.
The best place to start is referring to the FAQs on the package Github page.
First, if you have a Windows computer, you should install Rtools. If you have a Mac, then you should install Xcode.
Once you have the program relevant to your computer, then you can install brms
as usual:
install.packages("brms")