install.packages(c("tidyverse"))
R Resources
Getting Help
- Crowd-sourced R functions
- Interactive RStudio tutorials on various topics, including R basics and visualizing data
- Markdown (Quarto) basics, and tutorial
- RStudio cheatsheets
- Google! If you have a question about R, you can be fairly certain that someone else has already asked it. Google is your best friend for answering questions about R. I recommend adding “R tidyverse” to the search term. For example, to find out how to make a scatterplot, try searching “scatterplot R tidyverse”.
Getting Started
Follow these instructions to set up the software that we’ll be using throughout the semester. Even if you’ve already downloaded both R and RStudio, you’ll want to re-download to make sure that you have the most current versions.
If you have issues getting R and RStudio installed, you can use Macalester’s RStudio server. After you log in with your Macalester credentials, you will be able to work with a web version of RStudio.
Required: Change the default file download location for your internet browser.
- Generally by default, internet browsers automatically save all files to the
Downloads
folder on your computer. This does not encourage good file organization practices. You need to change this option so that your browser asks you where to save each file before downloading it. - This page has information on how to do this for the most common browsers.
Required: Create a STAT155
folder on your Desktop or in your Documents folder. Within the STAT155
folder create 3 subfolders:
Activities
Practice Problems
Project
Required: Download R and RStudio by following the directions below.
- FIRST: Download R here.
- In the top section, you will see three links “Download R for …”
- Choose the link that corresponds to your computer.
- As of August 27, 2024, the latest version of R is 4.4.1 (“Race for Your Life”).
- SECOND: Download RStudio here.
- Click the button under step 2 to install the version of RStudio recommended for your computer.
- As of August 27, 2024, the latest version of RStudio is 2024.04.2+764.
Required: Install required packages.
- An R package is an extra bit of functionality that will help us in our data analysis efforts in a variety of ways.
- Open RStudio and click inside the Console pane (by default, the bottom left pane). Copy and paste the following command into the Console. You should see the text below appear to the right of the
>
, which is called the R prompt. After you paste, hit Enter.
- You will see a lot of text from status messages appearing in the Console as the packages are being installed. Wait until you see the
>
again. - Enter the command
library(tidyverse)
and hit Enter.
If you see an error message, then there was a problem installing the package. Talk to the instructor or a preceptor for help. - Quit RStudio. You’re done setting up!
Optional: For a tour of RStudio features, watch this video. It also shows you how to customize the layout and color scheme of RStudio.
Required: Set essential RStudio options.
Go to Edit > Preferences (or Settings…) > General
Navigate to the “Workspace” section. You’ll see 2 options:
- Restore
.RData
into workspace at startup: Leave this unchecked - Save workspace to
.RData
on exit: Select “Never”
Without doing this RStudio will save and reload everything that you’ve been working on from the start of the semester. Since we’ll be working with new data each class, we want to keep our digital environment clean. Essentially, this is like an artist getting a clean canvas for each new painting rather than trying to paint all paintings on a single canvas.