Find path to package files

base-r
packages

#1

Is there a function that I can use to find the location of a package within the filesystem? Something like:

some_function("dplyr")
#> /Library/Frameworks/R.framework/Versions/3.4/Resources/library/dplyr

I've taken a look at .libPaths() and various bits and pieces used in package loading (like getExportedValue and getNamespace), but I've come a little stuck.

Does anyone have any sage advise, helpful pointers, or useful blog posts lying around?


#2

Found it:

getNamespaceInfo("dplyr", "path")

#3

There is also ?system.file that probably does what you want. I usually look for DESCRIPTION of the package in question.


#4

Ah yeah this looks even better


#5

To find the package path on the system, you have also the find.package function
https://www.rdocumentation.org/packages/base/versions/3.5.0/topics/find.package