List exported objects from R package without attaching it

痴心易碎 提交于 2019-12-08 16:39:28

问题


Is there a way to list the objects that a package exports, without actually attaching it? I tried

ls(loadNamespace("ggplot2"))

However this shows all of the defined and imported objects in this package. Instead I would like to see only the exported names. I.e. I would like the result of

library(ggplot2)
ls("package:ggplot2")

But without actually attaching the package to my search path.


回答1:


You could use documented getNamespaceExports("ggplot2").




回答2:


Ah found it. The undocumented

ls(getNamespaceInfo(mynamespace, "exports"));

Seems to do the trick.



来源:https://stackoverflow.com/questions/9658518/list-exported-objects-from-r-package-without-attaching-it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!