4.1 Installation

To download and install a package from CRAN, call the install.packages command on a string with the name of the desired package. You will get output describing the installation progress.

install.packages("readr")

You may be asked to choose a mirror; the RStudio mirror is a good choice as it will pick the nearest mirror automatically.

You only need to install a package once per machine, unless you need to update an already-installed package. Calling install.packages for an existing package will update it if there’s a more recent version on CRAN than on your machine.

You can view all of the installed packages using the installed.packages command. This will output a lot of information for each package, so if you only want a list of the installed package names, you can specify that you want the “Package” column. I like to look at this as a vector.

as.vector(installed.packages()[,"Package"])