In R statistical procedures are organized into groups of related functions and are called packages. The base version of R ships with built-in packages, which are loaded by default when we start R. Many more functions, which drastically extend the functionality of base R, are available from contributed packages, packages developed by users in the R community. Anyone can write and upload a properly formatted contributed package to the CRAN servers.

In order to download a contributed package and make use of therein provided functions, we have to type install.packages("PACKAGE-NAME") into the R console. (Note the quotation marks!) For example, in order to download the quite popular ggplot2 package, a package for data visualization, we type

install.packages("ggplot2")

Once downloaded, we can access the bundle of new functions within R by typing library(PACKAGE-NAME). Note, that this time we write the package name without quotation marks! With respect to our example from above, we write:

library(ggplot2)

If everything worked out fine and we do not get any error message all the functions are now available within R. It is worth noting that in some cases you do not want to load the whole package, but you just want to use one particular function of a package. If you already downloaded the package, you may access function of a package by using the :: operator in the form of PACKAGE-NAME::FUNCTION-OF-INTEREST(...). With respect to the example from above, we make use of the ggplot() function from the ggplot2 package by typing the following command into your R console.

ggplot2::ggplot(...)