Reputation: 18580
I have created a package 'mypackage' (with a namespace 'mypackage' attached) In this package there is a function that I can call either with
'myfunction'
or
'mypackage::myfunction'
Now I want to replace myfunction by another version (updated).
I used to do
source(path)
where path is the path of a file where the updated 'myfunction' is defined
Now I moved to R 2.14.x and this system doesnt work because apparently R checks first if there is a function inside the same namespace, and if there is one, it uses this one and not the others.
My question: how can I push the updated function to be in the same namespace as the package one?
Upvotes: 6
Views: 2872
Reputation: 174813
See ?assignInNamespace
. For example
assignInNamespace("myfunction", foo, "mypackage")
will assign the object foo
to the object named "myfunction"
in namespace "mypackage"
. foo
can be whatever object you want, even myfunction
but you will need to be careful to ensure you call mypackage::myfunction
if you also have myfunction
in the global environment/workspace.
Upvotes: 9