Reputation: 109844
This works:
help(package="ggplot2")
This does not:
x <-"ggplot2"
help(package=x)
# Error in find.package(pkgName, lib.loc, verbose = verbose) :
# there is no package called ‘x’
How can I make it so that I can pass x to help to open the help page?
Upvotes: 6
Views: 131
Reputation: 263311
Both help
and library
calls for interpreting "character" class input can be constructed with do.call
x <-"ggplot2"
do.call(library, list(x))
do.call(help, list(package=x))
Upvotes: 4
Reputation: 173527
Put the variable in parentheses:
x <-"ggplot2"
help(package=(x))
The help file for ?help
rather cryptically states for the package argument:
To avoid a name being deparsed use e.g. (pkg_ref) (see the examples).
Upvotes: 6