Chapter 8 Packages
Packages are user-provided extensions to the basic R system (comparable to an “add-on” or “extension” for some web browsers). Packages may contain custom datasets, additional functions, re-formulations of existing functions, and more. There are by now thousands of useful packages extending R.
A package named ABC
can be installed by
entering install.packages("ABC")
(with double quotes) and then require(ABC)
(without double quotes).
If a package in turn requires other packages, these are also installed
and loaded.
Some useful packages are the following:
datasets
: A wide variety of datasets, for exploration and education. This package is now integrated within R (see Help ondatasets
).foreign
: Functions for reading and writing data stored by statistical packages such as Minitab, S, SAS, SPSS, Stata, Systat, and for reading CSV files (comma separated values) created by Microsoft Excel, and for reading and writing dBase files (R Core Team 2022).lattice
: Trellis graphics for R. The functions provide a powerful, elegant and flexible high-level data visualization system, using Trellis graphics, with an emphasis on multivariate data (Sarkar 2021).MASS
: Datasets and functions accompanying (Venables and Ripley 2002; Ripley 2022)languageR
: Datasets and functions accompanying (Baayen 2008; Baayen and Shafaei-Bajestan 2019).hqmisc
: Some convenience functions and an example dataset, by the present author (Quené 2014), and used in this booklet.tidyverse
: A meta-package consisting of many other packages supporting your data science, such asdplyr
for data transformation,ggplot2
for data visualization, andrmarkdown
for reporting (also used for this booklet) (Wickham et al. 2019); all component packages can also be used separately.
Packages are stored on a so-called repository; the CRAN repository is
the most important one (https://cran.r-project.org/).
You should use a nearby mirror site of the CRAN
repository, by giving the command chooseCRANmirror()
.
Rstudio and R remember your chosen mirror site over multiple sessions.
Finally, to inspect the status of your current session in R, use the command sessionInfo()
. This will return a listing of technical information, locale settings, all attached packages, and all loaded packages, with version info for each.