[R] modify function in a package
dwinsemius at comcast.net
Fri Sep 26 02:14:30 CEST 2014
On Sep 25, 2014, at 11:21 AM, C Lin wrote:
> Dear R users,
> There is a package called NanoStringNorm with a function called NanoStringNorm.
> What I want to do is to change the NanoStringNorm function from the package with my own copy that is written in my.nanostringnorm.R.
> But if I do the following:
> unlockBinding("NanoStringNorm", as.environment("package:NanoStringNorm")) ;
> assign("NanoStringNorm", NanoStringNorm, "package:NanoStringNorm") ;
> Although, it now correctly called my NanoStringNorm, it doesn't recognize a function called inside my NanoStringNorm that called another functions in the NanoStringNorm package.
> So, I have to change all such functionswith NanoStringNorm:::function.name.
> How should I replace the NanoStringNorm function but still able to call other function in the package?
> I still have package NanoStringNorm in my search path but somehow it can't find the other function.
Take a look at assignInNamespace. It's also possible to set teh environment of a function:
Alameda, CA, USA
More information about the R-help