Reputation: 293
I need to change the definition of a variable that is contained in the namespace of the package I am working with, but I cannot find the definition anywhere. I can identify it like this
> library("MyPackage")
> getAnywhere(MyVariable)
A single object matching ‘MyVariable’ was found
It was found in the following places
namespace:MyPackage
with value ...
I can also see it when I run
> env = asNamespace("MyPackage")
> ls(envir = env)
However, it is not contained in the NAMESPACE file of the project folder. So I am wondering, if it is not contained in the NAMESPACE file, where can it possibly come from? Could it come from another package, even though getAnywhere() links to MyPackage? In that case, should I be able to see it in the NAMESPACE file from that package?
Upvotes: 1
Views: 162
Reputation: 9087
The NAMESPACE
file is for imports and exports. If a variable isn't exported by the package (i.e. it is an internal variable that they don't really want you to use), it won't be in there.
MyVariable
could have come from anywhere in the package.
If you want to access it, use :::
. :::
can access unexported variables whereas ::
only accesses exported variables.
MyPackage:::MyVariable
If you want to modify it, use assignInNamespace
assignInNamespace("MyVariable", "NEW VALUE", ns = "MyPackage")
Upvotes: 1