简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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