josiekre
josiekre

Reputation: 803

What is the "::" in R?

I am seeing the use of "::" more in R (perhaps exclusively by Hadley Wickham packages), but I cannot find documentation specifying its exact use cases. Examples include:

packrat::init()

or

devtools::install_github("rstudio/packrat")

Upvotes: 0

Views: 208

Answers (1)

Fernando
Fernando

Reputation: 7905

Try

 ?`::`

From R help:

For a package pkg, pkg::name returns the value of the exported variable name in namespace pkg, whereas pkg:::name returns the value of the internal variable name. The namespace will be loaded if it was not loaded before the call, but the package will not be attached to the search path.

Specifying a variable or package that does not exist is an error.

Note that pkg::name does not access the objects in the environment package:pkg (which does not exist until the package's namespace is attached): the latter may contain objects not exported from the namespace. It can access datasets made available by lazy-loading.

Upvotes: 2

Related Questions