0

How can I list all the identifiers (function names, variable names, etc.) that would be added1 to my current environment if I were to run

library(some.package)

I want to do this without actually adding all those identifiers to my current environment.


1 Point of pedantry: I use the verb "added" somewhat loosely here, to refer to not only those names from some.package that would be entirely new to the current environment, but also those that would shadow names already existing in the current environment.

kjo
  • 33,683
  • 52
  • 148
  • 265
  • You can usually find the functions in the NAMESPACE file (as well as recursively in the NAMESPACE files of all packages that are depended on or imported entirely). This does not work if a regex pattern is used for exporting, which is not common for the more important packages nowadays. If `LazyData: true` in the DESCRIPTION file, you'd also need to check the data directory of the package. There is probably something else that I'm forgetting. Why do you need this? – Roland Jul 27 '16 at 13:56
  • 1
    Can you clarify what you mean by "current environment"? Attaching a package adds nothing to the global environment. – Roland Jul 27 '16 at 14:27
  • @Roland: I probably did not word/set up this question properly (I'm very much of a novice when it comes to R); I just want to see what `library(some.package)` would "bring in", without actually running `library(some.package)`. Admittedly "bring in" is very vague. The way I framed my question was a clumsy attempt to make this "bring in" business a bit less vague. I gather from your question that this attempt wasn't very successful. – kjo Jul 27 '16 at 14:41

1 Answers1

4

Are you perhaps looking for this?

getNamespaceExports("stringr")

EDIT:

For data you could do something like

data(package = 'ggplot2')[['results']][, 'Item']
sbstn
  • 628
  • 3
  • 7