Find path to package files

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?

1 Like

Found it:

getNamespaceInfo("dplyr", "path")
1 Like

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

1 Like

Ah yeah this looks even better

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

1 Like