兔子先生

Skip to Main Content

Installing and Loading Packages

How to Download and Install an R Package

  • Packages menu (0:15)
  • Installing a package (1:06)
  • Loading a package (2:47)
  • Checking what packages are already loaded (3:48)
  • Total length (4:19)

There are three steps to implementing packages in R.

  1. Know the name of the package – sometimes, you will need to google what you are trying to do in order to get the name of the package
  2. Download the package – This can be accomplished in one of two ways:
    • Option a) from within RStudio, click the Packages tab, then click Install, begin to type the name of the package in the middle box, and click install (note that leaving Install Dependences checked will download any additional packages needed to use all capabilities of the package you are currently downloading)
    • Option b) from within the console window or from within a script, run install.packages('package name'). Note: both the period in the function call and the quotation marks around the package name are necessary.
  3. Load, or install, the package – type and run library(package name) from within your script window or as a line in the Console window. Note: quotation marks should NOT be used when calling the library() function.

Be aware that sometimes warning messages will be given in the command window when installing certain packages indicating that the package was built using an older version of R. Except in rare instances, these warnings can be ignored since "older" packages are usually still compatible with newer versions of R.

Ready to take your skills to the next level?

Center for Analytics and Data Science

165 McVey Data Science Building
105 Tallawanda Rd
Oxford, OH 45056