On Fri, 27 Oct 2006 15:54:40 +0100, Tom McCallum <[EMAIL PROTECTED]> wrote:
> On Fri, 27 Oct 2006 14:49:15 +0100, Paul Roebuck <[EMAIL PROTECTED]> > wrote: > >> On Fri, 27 Oct 2006, Tom McCallum wrote: >> >>> I have a function f which does something using a function g. Function >>> f >>> is in a library and g has a default stub in the library but will be >>> mainly >>> overloaded in a later R script. For example: >>> >>> ########## In a compiled package 'P' ################# >>> g <- function() { >>> cat("Original function g"); >>> } >>> >>> f <- function( newGsource=NULL ) { >>> if( is.null(newGsource) == FALSE ) { >>> source( newGsource ); # load new function g >>> } >>> g(); >>> return(1); >>> } >>> ##################################################### >>> >>> If I call f() then I get "Original function g". >>> >>> But I want to overload g so I do the following in the file newg.R: >>> >>> ############### CONTENTS of newg.R ########################## >>> g <- function() { >>> cat("New function g in newg.R"); >>> } >>> ################ END CONTENTS ############################### >>> >>> and call f( newGsource="newg.R" ) but I still get "Original function >>> g". >>> >>> Any suggestions? >> >> ?environment >> >> ---------------------------------------------------------- >> SIGSIG -- signature too long (core dumped) >> >> > > Thanks for that, have almost figured out how to do it, have got my > namespace but when I "assign" the new value > I get "cannot change value of a locked binding". Is there any way to say > that a particular item in a package > is able to be overridden using assign? > > I assume when I export a function in the NAMESPACE file it is locking the > value to the name. So I assume it is here I need > to change something - if this is even possible to do. > > Cheers > > Tom > found the use of assignInNamespace - done! Thanks for your help. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel