nilsole
nilsole

Reputation: 1723

Get package by variable

Using a character variable pkg_var containing a package name: How can I get an internal object of that package?

I am looking for something like getPackage(x = pkg_var):::internal_object

mypackage:::internal_object works of course, but is hard-coded.

Upvotes: 0

Views: 40

Answers (1)

Roland
Roland

Reputation: 132706

Use getFromNamespace:

getFromNamespace("cor.test.default", "stats")
#returns the function

Upvotes: 2

Related Questions