1 Introduction to R and RStudio
1.1 Welcome!
This session will get you up and running with R and RStudio, the tools we’ll be using throughout this module. You’ll learn how to install the software, explore the RStudio interface, and run your first R commands. We’ll also cover the crucial role of version control for all of your projects.
1.2 Learning Objectives
- Install R and RStudio.
- Understand the different panels in RStudio.
- Run basic R commands.
- Install and load R packages.
- Download sample data.
- Inspect a csv file using RStudio.
- Understand the basics of Version Control
- Understand the basics of a working branch in version control
1.3 Installing R
- Go to the CRAN website: https://cran.r-project.org/
- Choose your operating system: (Windows, macOS, or Linux)
- Download the installer: Select the appropriate download link for your system.
- Run the installer: Follow the on-screen instructions to install R.
1.4 Installing RStudio
RStudio is an integrated development environment (IDE) that makes working with R much easier and more productive.
- Go to the RStudio website: https://www.rstudio.com/products/rstudio/download/
- Download RStudio Desktop: Select the free RStudio Desktop version.
- Choose your operating system: Select the appropriate installer for your system.
- Run the installer: Follow the on-screen instructions to install RStudio.
1.5 Exploring RStudio
Open RStudio. You’ll see four main panels:
- Source Editor (Top-Left): This is where you write and save your R scripts.
- Console (Bottom-Left): This is where you execute individual R commands and see the output.
- Environment/History (Top-Right):
- Environment: Shows a list of loaded data, variables, and functions.
- History: Shows a history of commands you’ve entered.
- Files/Plots/Packages/Help (Bottom-Right):
- Files: Allows you to browse your computer’s file system.
- Plots: Displays any plots or graphs you create.
- Packages: Allows you to install, update, and load R packages.
- Help: Provides documentation for R functions and packages.