Installing R and R Studio

You can start by installing both R and R studio.

Download R: https://www.r-project.org/

Download R Studio Desktop: https://rstudio.com/products/rstudio/

For more details, learnr provides a walkthrough of how to set up R and Rstudio: https://learnr-examples.shinyapps.io/ex-setup-r/#section-welcome

Base R

Many operations work in base R. This means they can be run without loading any packages. For example, basic math and variable assignments do not require any packages.

2+2
## [1] 4
x = 4
x + 1
## [1] 5

Packages

For more advanced R, users need to install packages and load them into the environment.

If this is the first time using a package, the user needs to first install the package (install.packages("packagename"), where packagename is replaced with the enquoted ("") name of the package to be installed).

To load a package into the environment, use library("packagename"). R requires that you load packages that you need at the beginning of every session.

Resources for learning R: swirl

To get started feeling more comfortable with R, I would recommend you give the “swirl” package a try. It is pretty fun and helps you start to grasp the basic R syntax. Use the install.packages command to install it. Then, you can use library() to call the swirl package, loading it into your workspace.

From here, the swirl package should mostly guide you the rest of the way. There are several modules you can complete. The R Programming course is a good start. You can see more about the swirl package here: https://github.com/swirldev/swirl_courses#swirl-courses

install.packages ("swirl")
library(swirl)
install_course("R Programming")  #Loading a course in "swirl"
swirl()