February 1, 2019

R Packages

Packages add new capabilities to R.

Package contains: - DESCRIPTION – Name, short description, version, dependencies - R code - Man pages (help) for new code

Package may also contain: - SRC: C, Fortran, Java, … code to add functionality or to link to other tools (e.g., a database) - Data: Sample data to test functions - Vingettes: Longer narrative help that describes how to do something.

Finding new R packages

Three Steps – Download, Install and Load

  1. First, you must download the package code (either source or compiled to your computer)
  2. Then the package must be installed in a library directory that R knows about.
  • The install.packages(name) function will do steps 1 and 2
  1. When you want to use functions from the package, you need to load them into the workspace.
  • This can be done with library(name) or require(name).

Slide with Bullets

  • Bullet 1
  • Bullet 2
  • Bullet 3

Slide with R Output

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Slide with Plot