Skip to Main Content

Intro to R Programming

R is a powerful tool for data analysis and visualization; this guide will provide resources to get you started with this programming language!

What are R Packages?

Packages are created by R users to expand what you can do beyond base R functions. A package is a collection of functions, data sets, and other R objects grouped together under a common name.

You can search for and install packages from several repositories: Comprehensive R Archive Network (CRAN), Bioconductor, GitHub, etc.

In the 'Packages' tab of the bottom right pane of RStudio, click 'Install' to check for newer package versions and to install updates. Click the rightmost 'X' button to uninstall packages.

Installing Packages

Two methods to install packages in RStudio:

  1.  Click the 'Install' button in the Packages tab of the bottom right pane. The default option is to install from the Repository (CRAN). Start typing the package name, and suggestions will appear. Install to your R Library directory on your computer, leaving 'Install dependencies' ticked by default.
  2.  In the Script Editor, type install.packages("NameOfPackage")

Loading Packages

Two options to load packages in RStudio:

  1.  Select the checkbox next to the package name in the Packages tab of the bottom right pane
  2.  Write the code in the Script Editor library("NameOfPackage")

The best practice is to only load the packages you need, to save memory and processing power from your session!