2 Installing R, RStudio, and Git and registering a GitHub account
2.1 Register a GitHub account
For this module, you will need a GitHub account to be able to receive the code materials and assignments that will be provided. This is the mechanism by which these materials will be distributed. Hence you will need to register an account with GitHub (if you don’t already have one). It’s free!
Please follow the guidance descibed here regarding best practice in GitHub username to use and other tips.
2.2 Setup for Windows machines
2.2.1 Install R for Windows machines
Following is a simple guide to installing R and RStudio and other required software on Windows machines.
Important that R is installed first. R is the main software and is needed for RStudio to work properly. R should always be installed first.
Go to https://cran.r-project.org
Click on link that says Download R for Windows
Then click on the link that says install R for the first time
Then click on Download R-4.X.X for Windows. This will start the download process.
Once downloaded, go to the .exe
file in your Downloads
folder, double-click and follow all the install prompts, selecting recommended options all the time
2.2.2 Install RStudio
This step requires that step 1 has been done and was successful.
Go to https://posit.co/download/rstudio-desktop/
Select the download specific for your Windows machine.
Once downloaded, double-click on .exe
file downloaded to your Downloads
folder and then follow all install prompts, always selecting recommended options.
2.2.3 Install Rtools
For the things that you will be taught in the Open and Reproducibile Science Lecture Series, you we will need to expand the installation of R by installing the Rtools
software from R.
The download link is https://cran.r-project.org/bin/windows/Rtools/rtools42/rtools.html if you have installed R version 4.2.0 (or higher).
Once you have downloaded the .exe
file, double-click on the .exe
file and follow all install prompts. Choose all the recommended options.
2.2.4 Install Git for Windows
For the things that you will be taught in the Open and Reproducibile Science Lecture Series, you we will need to install Git for Windows.
If your machine is 64-bit machine (most likely the case if your computer is new and running Windows 10 or later) -
Use this download link - https://github.com/git-for-windows/git/releases/latest - to download the latest version of git. Make sure to choose the appropriate download for your machine (i.e., if you have a 64-bit machine then select the download for 64-bit machines; if you have a 32-bit machine then select the download for 32-bit machines)
Once you have downloaded the .exe
file, double-click it and then follow all install prompts. Choose all recommended options.
2.3 Setup for macOS machines
2.3.1 Install R for macOS machines
Following is a simple guide to installing R and RStudio and other required software on macOS machines.
Important that R is installed first. R is the main software and is needed for RStudio to work properly. R should always be installed first.
Go to https://cran.r-project.org
Click on link that says Download R for macOS
You will have two choices of R versions to install. Make sure to install the appropriate version for your macOS version (Apple Silicon vs Apple Intel version). Click on the download link for your macOS version. This will start the download process of the .pkg
file specific for installing in macOS computers.
Once downloaded, go to the .pkg
file in your Downloads
folder, double-click and follow all the install prompts, selecting recommended options all the time
2.3.2 Install RStudio
This step requires that step 1 has been done and was successful.
Go to https://posit.co/download/rstudio-desktop/
Select the download specific for your macOS machine.
Once downloaded, double-click on .dmg
file downloaded to your Downloads
folder and then follow all install prompts, always selecting recommended options.
2.3.3 Install git for macOS
For the things that you will be taught in the Open and Reproducibile Science Lecture Series, you we will need to install git for macOS. Apple machines are already pre-installed with git
but it is usually an Apple specific version of git and tends to be older and not configured in the way we need it. So we need to install another version of it that comes with Apple’s Xcode command line tools
.
To install, go to the macOS terminal and type the following command:
xcode-select --install
2.4 Setup Git and GitHub for all machines
2.4.1 Introduce yourself to Git
In the shell or terminal, issue the following commands:
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL REGISTERED WITH GITHUB"
Then check whether Git has indeed changed the configurations to what you have specified by looking at the output of the following shell or terminal command:
git config --global --list
2.4.2 Connecting Git, GitHub, and RStudio
- Create a GitHUB personal access token for HTTPS access to GitHub
Interacting with a remote Git server such as GitHub requires creating security credentials that proves you are a specific user (think of it as a digital ID that lets the remote Git server such as GitHub know that you are who you say you are) who is allowed to do whatever you are asking to do.
There are different ways to securely identify yourself. For our purposes, we will use HTTPS access using a personal access token (PAT)
.
To create a token, go to https://github.com/settings/tokens
- Name your PAT
Give this token a name that would remind you of what this token is for. We recommend calling it rstudio
as it is the token we will use to connect/communicate with GitHub via RStudio. You can name it anything for as long as you remember what this token is for.
- Select a validity period
It is always good practice to give the PAT a fixed validity period. Note that after said validity period, you will need to go through this process again and create a new PAT.
- Select the appropriate scopes
For our purposes, we recommend selecting repo
, user
, and workflow
.
- Click on
Generate token
Once you click on Generate token
, your PAT will be shown to you on the browser window. Make sure you copy this PAT right away. Once you move away from the current browser window, the PAT will not be viewable anymore.
- Store your PAT
It is essential that you store your PAT for future use. Treat this as you would your password. The best practice is to keep your PAT in a secure way such as using a password manager such as 1Password or LastPass.