How to define which variables or functions from a package are exported

devtools, export, namespaces, package, r

Solution

The `load_all` function has an `export_all` argument.

From `?load_all`

If TRUE (the default), export all objects. If FALSE, export only the objects that are listed as exports in the NAMESPACE file.

So, try using `export_all=FALSE` in your `load_all` call.

Problem

My R package uses an internal variable `x`. If I load the package (I've only tried using `devtools::load_all`), then `x` doesn't appear in the `ls()` list, but it does have a value. How can I avoid this? I'm fine with the user being able to access the variable with `myPackage::x`, but not simply `x`.

Original source