Closed yonicd closed 5 years ago
Several authors have contributed mice
imputation functions in packages. Did you check how others, for example https://github.com/alexanderrobitzsch/miceadds, have implemented this?
thank you for the reference!
Looking at that link, it seems that @alexanderrobitzsch forked {mice} and adjusted (adding more imputation functions and Rcpp calls) to his needs.
OK, the miceadds
approach is easy, and it works.
Perhaps, instead of trying to change the mice
namespace, you could try to alter the environment of your new function. See https://stackoverflow.com/questions/3094232/add-objects-to-package-namespace.
Thanks for the link.
This is what I did in the adhoc solution. I couldn't get this to work for internal function of my package that I am building.
ie
mypkg:::foo
is forced by construct to be part of mypkg
namespace. If I force that function into the .GlobalEnv
then I can set the environment to another ns like in the link you sent, but that raises a flag in R CMD CHECK since I am exporting an object to the .GlobalEnv
I am afraid I have no further suggestions.
ok. thank you for the links. i'll ping again if I find a solution (other than forking)
in {mice} there is no S3 to add a user defined imputation method, only built in methods.
I created a global function and assigned it to the {mice} namespace, which is then picked up by the wrapper function and things work fine be it in a ad-hoc solution.
Now I want to create a package that uses that function without assigning it to the global environment which triggers R CMD CHECK.
Is there a way to do this that I am missing?
https://github.com/stefvanbuuren/mice/blob/7b5aa7012ae10af07fb9bc395a97f461007cf6a8/R/sampler.R#L217_L224