Install R & RStudio
Why R & RStudio?
R is the industry standard for statistical analysis, data visualization, and reproducible research in mass communications. RStudio is the professional interface that makes R accessible and powerful. Together, they’re essential tools for any Communication Liaison who works with data.
In this course, you’ll use R to: - Clean and analyze data from surveys and content analysis - Create publication-ready visualizations and reports - Build reproducible workflows for your research - Collaborate on data analysis projects
What You’ll Install
- R — The programming language (free, open-source)
- RStudio — The professional development environment (free, open-source)
This is a two-step process: install R first, then RStudio.
Step 1: Install R
For Windows
- Go to r-project.org
- Click “Download R” in the left menu
- Click the “Download R for Windows” link
- Click “base”
- Click “Download R X.X.X for Windows” (where X.X.X is the latest version number)
- Run the installer (
.exefile)- Click “Next” through all screens
- Accept the default installation location
- Accept all default components
- Click “Finish”
To verify installation: - Open PowerShell or Command Prompt - Type R --version - You should see R’s version information
For macOS
- Go to r-project.org
- Click “Download R” in the left menu
- Click “Download R for macOS”
- Download the appropriate
.pkgfile for your Mac:- Apple Silicon (M1/M2/M3 chips): Download the “ARM64” version
- Intel Macs: Download the “Intel 64” version
- Not sure? Click the Apple icon (top left) → “About This Mac” → check under “Processor”
- Run the installer (
.pkgfile)- Click through all prompts
- Accept the default installation location
- Restart your Mac
To verify installation: - Open Terminal - Type R --version - You should see R’s version information
For Linux (Ubuntu/Debian)
Open Terminal and run:
sudo apt update
sudo apt install r-baseTo verify: Type R --version in Terminal.
Step 2: Install RStudio
For Windows, macOS, or Linux
- Go to posit.co/download/rstudio-desktop/
- Scroll down to “All Installers” or “Download RStudio Desktop”
- Select your operating system:
- Windows: Download the
.exefile - macOS: Download the
.dmgfile - Linux: Download the appropriate
.debor.rpmfile
- Windows: Download the
- Run the installer
- Windows: Click through all default options
- Mac: Drag RStudio to Applications folder
- Linux: Follow the package manager prompts
- Open RStudio (you should see R is installed when you open it)
Step 3: Verify RStudio Works
- Open RStudio (should be in your Applications/Programs menu)
- You should see four panes:
- Top left: Script editor (blank)
- Bottom left: Console (shows
>prompt) - Top right: Environment & History
- Bottom right: Files, Plots, Packages, Help
- In the Console (bottom left), type this command and press Enter:
print("Hello, Communication Liaison!")- You should see the output:
[1] "Hello, Communication Liaison!"
If you see this output, you’re ready to go!
Step 4: Install Key Packages
RStudio comes with base R, but you’ll need additional packages for data analysis. Open RStudio and copy these commands into the Console one at a time:
For Data Analysis & Visualization
install.packages("tidyverse")This installs a collection of packages including: - ggplot2 — Create professional visualizations - dplyr — Clean and transform data - readr — Import data from CSV, Excel, etc. - tidyr — Reshape data
Wait for it to finish (you’ll see a blank > prompt when done)
For Survey Analysis
install.packages("likert")Used for analyzing Likert-scale survey responses.
For Reporting
install.packages("rmarkdown")Creates professional PDF and HTML reports from your analysis.
Optional: Statistics Packages
For later phases, you might want these too:
install.packages("lm.beta") # Standardized regression coefficients
install.packages("car") # Post-hoc tests and diagnostics
install.packages("ggstatsplot") # Statistical plots with test resultsStep 5: Create Your First R Project
RStudio projects help you organize your work. Let’s create one:
- In RStudio, click File → New Project
- Select New Directory → New Project
- Name your project
mc451-researchor similar - Choose where to save it (suggest
Documents) - Click Create Project
You should now see your project name in the top-right corner of RStudio.
Step 6: Test Your Setup with Data
Let’s make sure everything works by loading a dataset:
In the Console, type:
# Load the tidyverse library
library(tidyverse)
# Load a built-in dataset
data(mtcars)
# View the first few rows
head(mtcars)You should see a table with car data. If this works, your R setup is complete!
Understanding the RStudio Interface
| Area | Purpose |
|---|---|
| Top Left (Script Editor) | Write R code here and save as .R files |
| Bottom Left (Console) | Results appear here; you can type commands directly |
| Top Right (Environment) | Shows all variables and data you’ve loaded |
| Bottom Right (Files/Plots/Help) | Navigate files, view plots, access documentation |
Basic RStudio Workflow
- Create a new script: File → New File → R Script
- Write code: Type your commands in the script
- Run code: Select lines and press Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac)
- See results: Output appears in the Console or Plots pane
- Save your work: Ctrl+S or File → Save
Common First-Time Issues
“Command not found: R”
Problem: Your computer doesn’t recognize the R command.
Solution: - Try restarting your computer after installation - Check that R installed correctly (reinstall if needed) - On Mac/Linux, you may need to use /usr/bin/R instead
RStudio Opens But Doesn’t Find R
Problem: RStudio says “R not found” when you open it.
Solution: 1. Make sure you installed R first (before RStudio) 2. In RStudio, go to Tools → Global Options → General 3. Under “R sessions”, check the “R home directory” 4. If empty, browse to your R installation folder and select it 5. Click “OK”
“Error: Could not find function”
Problem: You get an error like could not find function "ggplot"
Solution: You need to load the package first. Run:
library(ggplot2) # or whichever package you needInstallation Stuck or Takes Forever
Problem: install.packages() command seems frozen.
Solution: 1. Press Escape to stop it 2. Try installing from a different CRAN mirror:
install.packages("tidyverse", repos="https://cloud.r-project.org")“Permission denied” Error (Mac/Linux)
Problem: Error when installing packages.
Solution: Try:
Sys.which("R") # Check where R is installedIf you’re still stuck, reach out during office hours.
Next Steps
- ✅ Installed R
- ✅ Installed RStudio
- ✅ Verified it works
- ✅ Installed key packages
- Next: Learn R basics with your first assignment in Phase 2
Resources
- Official R Website: r-project.org
- RStudio Documentation: posit.co/support/
- Bookdown R for Data Science: r4ds.had.co.nz (free online book)
- My Open-Source R Course: bookdown.org/alex_leith/mc451/ (free, written for this class!)
Questions?
R and RStudio have a learning curve, but the payoff is huge. If you run into issues:
- Check the troubleshooting section above
- Search stackoverflow.com for your error (others have likely encountered it)
- Visit office hours—we’ll debug together
- Email with your specific error message
You’ve got this! 💪