Installing R Packages from Cran:

install.packages("ggplot2") # To install an R package
install.packages(c("devtools", "lme4")) # To install multiple packages

If you want to use RStudio’s Graphical Interface to install packages:

Tools > Install Packages > type the desired packages in the appropriate box

Installing R packages from Bioconductor:

install.packages("BiocManager") # Install BiocManager from Cran
BiocManager::install("GenomicFeatures")

Use column vector c() in install() to install multiple packages.

Installing R packages from GitHub:

Take note of package name and its author.

install.packages("devtools")
library(devtools) # Load devtools using library() function
install_github("<author>/<package>")

Loading a package after installing it:

library(<package>) # To load the package; quotes ("") are not required

Or, loading packages using RStudio’s graphical interface:

Packages (bottom-right quadrant) > click on the corresponding checkbox

Updating packages:

packageVersion("<package>") # to check the version of a specific package
old.packages() # to identify which packages need an update
update.package() # to update all packages
install.packages("<package>") # to update a single package

To update using RStudio’s graphical interface:

Packages > Update > select the package you want to update

Unloading a package:

detach("package:<package>", unload = TRUE)

To unload packages from RStudio’s graphical interface:

un-check the checkbox corresponding to the package you want to unload

Uninstalling a package:

remove.packages("<package>")

To uninstall a package using graphical interface:

Click on the X at the end of the package line in the Packages tab

Getting help on a package:

help(package = "<package>") # to find out all the functions of a package
browseVignettes("<package>") # to get a detailed description of a package

Using the graphical interface, click on the package name.

Getting info regarding R version:

version
sessionInfo()