Find the paths to one or more packages.
1 2 3 4
character vector: the names of packages.
a character vector describing the location of R
library trees to search through, or
logical. Should this not give warnings or an error if the package is not found?
a logical. If
find.package returns path to the locations where the
given packages are found. If
loaded namespaces are searched before the libraries. If a package is
found more than once, the first match is used. Unless
TRUE a warning will be given about the named packages which are not
found, and an error if none are. If
verbose is true, warnings
about packages found more than once are given. For a package to be
returned it must contain a either a ‘Meta’ subdirectory or a
‘DESCRIPTION’ file containing a valid
version field, but
it need not be installed (it could be a source package if
lib.loc was set suitably).
find.package is not usually the right tool to find out if a
package is available for use: the only way to do that is to use
require to try to load it. It need not be installed for
the correct platform, it might have a version requirement not met by
the running version of R, there might be dependencies which are not
path.package returns the paths from which the named packages
were loaded, or if none were named, for all currently attached packages.
quiet = TRUE it will warn if some of the packages named
are not attached, and given an error if none are.
A character vector of paths of package directories.
normalizePath for path
1 2 3 4 5 6 7 8 9 10 11
try(find.package("knitr")) ## will not give an error, maybe a warning about *all* locations it is found: find.package("kitty", quiet=TRUE, verbose=TRUE) ## Find all .libPaths() entries a package is found: findPkgAll <- function(pkg) unlist(lapply(.libPaths(), function(lib) find.package(pkg, lib, quiet=TRUE, verbose=FALSE))) findPkgAll("MASS") findPkgAll("knitr")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.