In R the place where a package is installed is called library.
R does not automatically load all the installed packages.
To get a list of all loaded packages:
It also gives the path where those packages are in your hard drive.
To get the list of installed packages use:
We can install packages using the RStudio or the install.packages()
command:
If we want to install more than one package we need provide a vector with the package names.
Whenever there is a major release of R x.y you’ll need to re-install the packages.
R tries to install binary versions of the packages, and only when they are not available you’ll be prompted to compile them localy. This is easier on a Mac or linux machine.
By default packages are installed from The Comprehensive R Archive Network (CRAN).
You can get a list of all available packages in here.
CRAN Task Views has curated lists of packages per topic making it a great starting point to learn about the most commonly used packages for a given task.
An installed package cannot be used before being loaded.
To load and attach a package we use library()
:
When function names are masked we can get to desired function using: libraryname::functionname()
To unload/detach a package we use detach()
:
To get the list of all functions from a package:
It also provides useful additional information.
Watch the video below.