R - Package


R functionality is divided into a number of packages.

The package contained in the “base” system include utils, stats, datasets, graphics, grDevices, grid, methods, tools, parallel, compiler, splines, tcltk, stats4. And

The package recommended are boot, class, cluster, codetools, foreign, KernSmooth, lattice, mgcv, nlme, rpart, survival, MASS, spatial, nnet, Matrix.

There are about 4000 packages on the CRAN repository


  1. plyrTools for splitting, applying and combining data
  2. digest Create cryptographic hash digests of R objects
  3. ggplot2 An implementation of the Grammar of Graphics
  4. colorspace - Color Space Manipulation
  5. stringr Make it easier to work with strings



Search path for package. See R Admin - libPaths


Download and install Package with the following command from cran

install.packages("stringr", dependencies=TRUE)
  • From GitHub if not in Cran with devtools.
if (!require('devtools')) install.packages('devtools')
devtools::install_github('apache/[email protected]', subdir='R/pkg')
  • From the local disk
R -e "devtools::install('.')"

See also: librarian - install, update, and attach packages from CRAN and GitHub in the same function call.

Uninstall / Remove

remove.packages(pkgs, lib)

# Example


Installation location

Package are installed locally on Windows at: USER_HOME\Documents\R\win-library\


Package: RevoUtils
Version: 10.0.7
Date: 2018-01-03
RevoBuildID: {}
Title: Microsoft R Utility Package
Author: Microsoft Corporation
Maintainer: Microsoft Corporation <[email protected]>
SystemRequirements: R (>= 3.0.0)
Description: Utility functions for Microsoft R
License: GPL-2
Copyright: Microsoft Corporation
MRANDate: 2018-01-01
Built: R 3.4.3; ; 2018-01-02 22:34:00 UTC; windows

-- File: C:/Program Files/Microsoft/ML Server/R_SERVER/library/RevoUtils/Meta/package.rds 

get one info

[1] "2018-01-01"


The meta (description) of the package are in the DESCRIPTION file.

Example for sparklyr

Package: sparklyr
Type: Package
Title: R Interface to Apache Spark
Version: 0.5.4
[email protected]: c(
    person("Javier", "Luraschi", email = "[email protected]", role = c("aut", "cre")),
    person("Kevin", "Ushey", role = "aut", email = "[email protected]"),
    person("JJ", "Allaire", role = "aut", email = "[email protected]"),
    person(family = "RStudio", role = c("cph")),
    person(family = "The Apache Software Foundation", role = c("aut", "cph"))
Maintainer: Javier Luraschi <[email protected]>
Description: R interface to Apache Spark, a fast and general engine for big data
    processing, see <http://spark.apache.org>. This package supports connecting to
    local and remote Apache Spark clusters, provides a 'dplyr' compatible back-end,
    and provides an interface to Spark's built-in machine learning algorithms.
License: Apache License 2.0 | file LICENSE
URL: http://spark.rstudio.com
BugReports: https://github.com/rstudio/sparklyr/issues
LazyData: TRUE
RoxygenNote: 6.0.0
Depends: R (>= 3.1.2)
Imports: methods, lazyeval (>= 0.2.0), dplyr (>= 0.5.0), DBI (>= 0.6),
        readr (>= 0.2.0), digest, config, rappdirs, assertthat,
        rprojroot, withr, httr, jsonlite, base64enc
Suggests: testthat, RCurl, janeaustenr
NeedsCompilation: no
Packaged: 2017-04-25 06:40:26 UTC; javierluraschi
Author: Javier Luraschi [aut, cre],
  Kevin Ushey [aut],
  JJ Allaire [aut],
  RStudio [cph],
  The Apache Software Foundation [aut, cph]
Repository: CRAN
Date/Publication: 2017-04-25 07:24:39 UTC
Built: R 3.3.3; ; 2017-04-28 11:22:35 UTC; windows


To load package, use the library function



detach("package:RJDBC", unload = TRUE)

Verify is a package is loaded

 [1] ".GlobalEnv"        "tools:rstudio"     "package:stats"     "package:graphics" 
 [5] "package:grDevices" "package:utils"     "package:datasets"  "package:methods"  
 [9] "Autoloads"         "package:base"     

Creating a package


Get the help on one package


Documentation / Reference

Powered by ComboStrap