I have a function that is part of my own package. When called from namespace:package_name
, the function behaves slightly different than when it is called from R_GlobalEnv
. To find out why I want to debug the function.
To make debugging the function as easy as possible, I want to write the changes I made to the function to the namespace:package_name
environment, so I can immediately test it, but I cannot figure out how to do this.
If I type namespace:package_name
, it gives the environment at the bottom as follows:
<bytecode: 0x00000236403c9da0>
<environment: namespace:package_name>
But if I try environment(fun) <- namespace:package_name
, it says:
Error: object 'namespace' not found.
How do I set the environment of my function to the package environment?
EDIT:
Surprisingly fixInNamespace
does not leave the namespace
intact.