Installing R and RStudio
Getting Started with R
This guide covers the installation of R and RStudio, the essential tools for R programming.
What is R?
R is a free, open-source programming language for statistical computing and graphics.
What is RStudio?
RStudio is an integrated development environment (IDE) for R with syntax highlighting, code completion, and visualization tools.
Installation Guide
Installing R
Windows
- Go to the CRAN (Comprehensive R Archive Network) website
- Click on “Download R for Windows”
- Click on “base”
- Click on the download link for the latest version (e.g., “Download R-4.x.x for Windows”)
- Run the downloaded installer and follow the prompts
- Accept default settings or customize as needed
- Note installation location
macOS
- Go to the CRAN website
- Click on “Download R for macOS”
- Download the latest .pkg file for the system
- Open the downloaded file and follow installation instructions
Linux (Ubuntu/Debian)
Open a terminal window
Update your system’s package index:
sudo apt update
Install R:
sudo apt install r-base
Installing RStudio
After installing R, install RStudio:
- Go to the RStudio download page
- Download the installer for the operating system
- Run the installer and follow prompts
Verification
To verify installation:
Open RStudio
In the Console, type:
R.version
Press Enter to display R installation information
Package Installation
Install packages using:
install.packages("packagename")
Example - tidyverse installation:
install.packages("tidyverse")
Essential Packages
Recommended packages for beginners:
install.packages("dplyr") # Data manipulation and visualization
install.packages("rmarkdown") # Dynamic documents
install.packages("knitr") # Report generation
install.packages("shiny") # Interactive web applications
Troubleshooting
Common Issues on Windows
- Permission errors: Run RStudio as administrator
- Path too long errors: Install R in a directory with a shorter path
Common Issues on macOS
Package installation failures: Install development tools:
xcode-select --install
Common Issues on Linux
Missing dependencies: Install R dependencies:
sudo apt install libcurl4-openssl-dev libssl-dev libxml2-dev