Skip to Main Content
University of Oregon
UO Libraries

Digital Scholarship Workshop Materials

This guide will walk users through the process of downloading and installing R and RStudio.

What are Packages?

R packages are the fundamental unit of shareable code. These packages bundle together code, data, documentation, and tests that can be easily shared and replicated by others. The Comprehensive R Archive Network or CRAN, hosts close to ten thousand of these user-contributed packages, making them available to all users for installation and use.

Individual packages have various purposes. Some of these include importing and transferring data from other programs into a readable format in R, allowing users to import data directly from APIs (Application Program Interface), or changing the layouts of datasets for a tidier appearance. Overall, the main purpose of packages is to provide users with preexisting code to save time and effort when working in R and RStudio.

Installing Packages

Installing packages into R and RStudio can be done in two ways. The first sep for both is to select the package you wish to install. This can be done from CRAN (https://cran.r-project.org/web/packages/). This RStudio page also provides a list of suggested CRAN packages that may be useful to install. 

 
Installing a package into R:

Since R is command line only, there is one option when installing a package into R; using the function install.packages(). In the command line, type:

install.packages("name_of_package")
 
Installing a package into RStudio:

In RStudio there are two methods to install a package. This first is the same as above, using the install.packages() function. Again, in the command line, type:

install.packages("name_of_package")

 

The second option is using the user interface of RStudio. This option requires more steps, but those less comfortable with coding may find it more intuitive. However, we urge you to first try using the command line to install packages before referring to this option, as using the command line will assist in increasing your level of comfort with the R language. 

  1. The lower right hand pane of the user interface provides tabs labeled, "Files", "Plots", "Packages", "Help", and "Viewer". Select the Packages tab. 
  2. Once the Packages tab is selected, there will be two options; "Install" and "Update". Select Install
  3. The install window will open. The default setting will have the install location set on "Repository (CRAN, CRANestra)". Keep this setting when installing a CRAN package. 
  4. The packages line will be blank. Type the name of the package you wish to install. RStudio will recognize CRAN packages and provide a drop-down of suggested choices. Select the appropriate package. 
  5. Select Install at the bottom of the window. 

Essential Packages for UO Libraries R Workshops

The following is a list of packages that will be used throughout the University of Oregon Libraries' R Workshop Series. For those attending the workshop, instructors will assist in installation of the appropriate packages. For those who are unable to attend but wish to walk-through the provided materials on their own, please install the following packages using the instructions provided above. As a reminder, the function install.packages("name_of_package") can be used to install packages in both R and RStudio.

  • foreign: functions for reading and writing data stored by some versions of Stata, SAS, SPSS, Epi Info, Minitab, S, Systat and Weka, as well as some dBase files. 
  • httr: useful tools for working with HTTP organized by HTTP verbs (GET(), POST(), etc.) Configuration functions make it easy to control additional request components such as authenticate(), add_header(), etc.
  • blsAPI: allows users to request data for one or multiple series through the U.S. Bureau of Labor Statistics API. Users provide parameters as specified in (http://www.bls.gov/developers/api_signature.htm) and the function returns a JSON string
  • rjson: converts JSON objects into R objects and vice-versa
  • tidyjson: an easy and consistent way to turn JSON into tidy data frames that are natural to work with in 'dplyr', 'ggplot2' and other tools
  • ggplot2: a system for creating graphics based on "The Grammar of Graphics". You provide the data, tell 'ggplot2' how to map variables to aesthetics and what graphical primitives to use.