R is a free software environment made up of many user-written packages. In this tutorial, we work on how to get a list of installed packages, the package versions, the place of packages in R.
Managing R packages is essential for R users. Firstly, we will learn how to get a list of installed packages. Secondly, we go over finding version of the package. Thirdly, we will learn the pathways of the R packages installed. At last, we check whether a package is installed or not.
In this article, we will learn the answers of the following questions.
- How can I get a list of installed packages?
- How to find out which package version is loaded in R?
- How do I find where R packages are installed?
- How do you check if an R package has been installed?
We can see the installed packages with installed.packages() function. Then, we pull the packages and their versions.
packINFO <- as.data.frame(installed.packages())[,c("Package", "Version")] rownames(packINFO) <- NULL
Let’s see the head of installed packages and their versions.
head(packINFO) ## Package Version ## 1 A3 1.0.0 ## 2 ABCanalysis 1.2.1 ## 3 abind 1.4-5 ## 4 ada 2.0-5 ## 5 admisc 0.30 ## 6 AER 1.2-10
Check Out: How to Install and Load a Package in R
How to Find Package Version in R
In this section, we learn how to find the package version in R. For instance, let’s find the version of onewaytests package (Dag et al., 2018).
packINFO[packINFO$Package == "onewaytests",] ## Package Version ## 300 onewaytests 2.7 packageVersion("onewaytests") ##  ‘2.7’ getNamespaceVersion("onewaytests") ## version ## "2.7"
Also Check: How to Change Working Directory in R
How to Find Where R Packages are Installed
We can find the pathways of the R packages installed with .libPaths() function.
.libPaths() ##  "C:/Users/osmandag/Documents/R/win-library/4.0" ##  "C:/Program Files/R/R-4.0.2/library"
Also Check: How to Import Data into R
How to Check If/Where an R Package is Installed
In this part, we learn how to check whether an R package is installed or not. For example, let’s check whether onewaytests package (Dag et al., 2018) is installed with system.file() function.
system.file(package = "onewaytests") ##  "C:/Users/osmandag/Documents/R/win-library/4.0/onewaytests"
The application of the codes is available in our youtube channel below.
Don’t forget to check: How to Download and Install R for Windows
Dag, O., Dolgun, A., Konar, N.M. (2018). onewaytests: An R Package for One-Way Tests in Independent Groups Designs. R Journal, 10(1), 175-199.