87

How we can get the list of installed packages by user in R along with its version?

I know about the command installed.packages() which will give information about all packages (base or non-base). But how we can get those installed by user to have something like this:

Package    Version
X          3.01
Y          2.0.1
Z          1.0.2

For all user installed packages (i.e. those package you installed via install.packages("X"))

4
  • perhaps useful r.789695.n4.nabble.com/…
    – user20650
    Jul 20, 2016 at 13:10
  • 6
    This is the first link I got after googling 'r installed user packages': <r-bloggers.com/…>. And does exactly what you want.
    – StatMan
    Jul 20, 2016 at 13:12
  • Do you mean just the non-base packages?
    – Hugh
    Jul 20, 2016 at 13:33
  • 8
    Try x <- installed.packages(); x[ is.na(x[,"Priority"]), c("Package", "Version")]
    – zx8754
    Jul 20, 2016 at 14:03

6 Answers 6

82

ref

ip = as.data.frame(installed.packages()[,c(1,3:4)])
ip = ip[is.na(ip$Priority),1:2,drop=FALSE]
ip
1
  • 4
    What is the difference between your answer and the one provided by @Ckkhamari above? (the code above is : str(allPackage <- installed.packages(.Library, priority = "high")); allPackage [, c(1,3:5)] . It gives a very different list of packages. The "ref" link does not explain anything. Feb 5, 2020 at 22:17
43

I just found another ways to see the list of the packages without writing any code:

  • Open RStudio
  • Navigate to Help --> R Help (from the menu above)
  • You will see the help panel opened.
  • Then follow, Reference --> Packages

There you are.


OR

  • Open R console
  • Navigate to Help --> Html help
  • Then follow, Reference --> Packages
1
  • This should be the accepted answer, it also tells you in what directory the packages are installed, under the user that is logged in. Feb 1 at 11:56
14
str(allPackage <- installed.packages(.Library, priority = "high"))

allPackage [, c(1,3:5)]

You will get all the active package List

9

Here's my solution.

tibble::tibble(
  Package = names(installed.packages()[,3]),
  Version = unname(installed.packages()[,3])
)

You can even filter some packages that you want to show.

pkg = tibble::tibble(
  Package = names(installed.packages()[,3]),
  Version = unname(installed.packages()[,3])
)

dplyr::filter(pkg, Package %in% c("tibble", "dplyr"))
5

If I develop an app or model and want to record the package versions used, I call sessionInfo()

2
  • 9
    sessionInfo() answers a subtly different question. It displays the attached and loaded packages, which is a subset of the installed packages on a machine. And sessionInfo() certainly won't help an admin enumerate the packages installed for other users (because their session isn't even active).
    – wibeasley
    Jun 25, 2018 at 23:26
  • 1
    sessionInfo() is useful when saving a dependencies file. This is my main use of the function and is not from an administrator's point-of-view. Oct 30, 2018 at 10:24
2

One trick would be to use library() and a window with all the packages will pop up

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.