简体   繁体   English

如何加载一个包,以便需要使用命名空间引用符号?

[英]How to load a package such that referring to symbols with namespace is needed?

How can I load a package but not put everything that it exports into the "main namespace"? 如何加载程序包,但不将导出的所有内容放入“主名称空间”?

library(myPackage) # exports myVar
myVar            # This works, but I want it not to work
myPackage::myVar # This works, and I do want it to work

For accessing the exported variables in a package, :: is sufficient. 要访问包中的导出变量, ::就足够了。 You don't need to load the package for this syntax to work. 您无需加载程序包即可使用此语法。 As ?":::" points out in the first paragraph of the Details section, the triple colon suggested by @csgillespie is intended for inspecting internal variables not exported by a package. 正如“ ?":::"在“详细信息”部分的第一段中指出的那样,@ csgillespie建议的三元冒号用于检查软件包未导出的内部变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM