Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass character package name to help function

Tags:

r

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?

like image 571
Tyler Rinker Avatar asked May 17 '12 14:05

Tyler Rinker


1 Answers

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).

like image 136
joran Avatar answered Oct 12 '22 02:10

joran