In previous chapters, you completed most tasks by using functions that were provided by others. The functions came from packages in the base R installation or from contributed packages downloaded from CRAN.
Installing a new package extends R’s functionality. For example, installing the mice package provides you with new ways of dealing with missing data. Installing the ggplot2 packages provides you with new ways of visualizing data. Many of R’s most powerful capabilities come from contributed packages.
Technically, a package is simply a set of functions, documentation, and data saved in a standardized format. A package allows you to organize your functions in a well-defined and fully documented manner and facilitates sharing your programs with others.
- To make a set of frequently used functions easily accessible, along with the documentation on how to use them.
- To create a set of examples and datasets that can be distributed to students in a classroom.
- To create a program (a set of interrelated functions) that can be used to solve a significant analytic problem (such as imputing missing values).
- To promote research reproducibility by organizing study data, analysis code, and documentation into a portable and standardized format.