R comes with a standard set of packages and includes base, datasets, utils, grDevices, graphics, stats, and methods. It provides a wide range of functions and datasets that are available by default. Other packages are available for download and installation. Once installed, they have to be loaded into the session in order to be used. The command
search() tells you which packages are loaded and ready to use.
Installing Package in R
To install a package for the first time, use
install. packages() command. Make sure you are connected to the internet.
Example, Installing Fincalc package
install.packages("FinCal")and press the Enter/Return key. R will automatically download and install Fincalc package.
- To load the installed package. Just type
library("FinCal")and press Enter/Return key.
Here comes a Trick: What if you want to install only if the package is not installed in your system?
Use the following command:
This will install FinCal if it is not previously installed. Incase if it previously installed the above command will skip the download and load the package. Isn’t that handy?!
Updating package in R
You only need to install a package once. But like any software, packages are often updated by their authors. Use the command
update.packages() to update any packages that you’ve installed.
For example: To update “FinCal” package use
To know which version of R is installed Read: How to check the version of R language installed?