install.packages("tidyverse")
Installing / Updating R & RStudio
Your workflow refers to the series of good habits you get into in your coding process, that help save you time and headache down the road.
This document outlines our suggestions for getting going with your workflow. None of these items is required for the course; they will simply make your life easier down the road.
1 Updating R
Each of you should have R already installed on your computer, but you might not have the most up to date version of R! Do not ignore these instructions. If you neglect to update your version of R, you may find that updating a package will make it so your code will not run.
- Step 1: Open RStudio
- Step 2: At the top of the the Console it will say what version of R you are using
If the version is not 4.4.3 (like the image above), you need to update your version of R! The simplest way to do this is to follow the instructions below to install R.
2 Installing R
Download and install R by going to https://cloud.r-project.org/. Here, you will find three options for installing R—click on the option for your computer’s operating system.
If you are a Windows user:
Click on “Download R for Windows”
Click on “base”
Click on the Download link.
When you open the execution file (
.exe
) you will be prompted with a variety of questions about installing R. Feel free to use the default features / settings that come with R (continue to click “Ok” until the download starts).
Beware that if you had a previous version of R downloaded on your PC, that old version will not be deleted when you download the most recent version of R. We do not want to have two versions of R installed, as your computer can get confused what version of R to use. So, you need to remove the old version of R.
To do this you need to:
- Navigate to your computer’s settings
- Click on the “Apps” option on the left-hand panel
- Search for or scroll down to R
- Find the older version of R
- Click on the
...
on the right side - Select “Uninstall”
If you are macOS user:
Click on “Download R for (Mac) OS X”
Under “Latest release:” click on R-X.X.X.pkg, where R-X.X.X is the version number. For example, the latest version of R as of July 1, 2024 was R-4.4.1 (Race for Your Life).
When installing, use the default features / settings that come with R (click Ok until the download starts).
3 Updating RStudio
RStudio can be downloaded here
The most recent version of RStudio is 2024.12.1+563. You can check if you are using the most recent version of RStudio by:
- Opening RStudio
- Clicking on “Help”
- Selecting “Check for Updates”
- Choosing “Quit and Download” if there is an update available
4 Installing / Updating the tidyverse
In this class, we will make heavy use of the tidyverse
packages.
If you have not used the tidyverse
before, type the following into your console:
If you have used the tidyverse
before, you only need to update packages. Type the following into your console:
library(tidyverse)
tidyverse_update()
Then follow the instructions that print out to update a few of your tidyverse packages.
5 Configure your options
There are a few settings we recommend that you change right away in RStudio.
R Workspace
First, you should not save your environment when you close RStudio:
Code Chunk Output
Second, make a deliberate choice about where your chunks will evaluate when you run that. That is, if you reference files, are you referencing them relative to your Project, or relative to your Quarto Document (which might live in a subfolder or even outside the project).
6 Project-based workflow
We strongly recommend that you adopt a project-oriented approach to your R work. That is, you should never open R or RStudio directly; you should only open the project you intend to work on.
This resource provides an excellent explanation of why and how to use projects.