path_package differs from system.file() in that it always returns an error if the package does not exist. It also returns a different error if the file within the package does not exist.

path_package(package, ...)

Arguments

package

Name of the package to in which to search

...

Additional paths appended to the package path by path().

Examples

path_package("base")
#> /Library/Frameworks/R.framework/Resources/library/base
path_package("stats")
#> /Library/Frameworks/R.framework/Resources/library/stats
path_package("base", "INDEX")
#> /Library/Frameworks/R.framework/Resources/library/base/INDEX
path_package("splines", "help", "AnIndex")
#> /Library/Frameworks/R.framework/Resources/library/splines/help/AnIndex