Re: [R] when setting environment: target of assignment expands to non-language object

2010-04-27 Thread Gabor Grothendieck
The environment of your function, as written, is the global environment which means that free variables in it are looked up there but you want it so that those free variables are looked up in the nlme namespace first so set its environment as shown: library(nlme) nlme <- asNamespace("nlme") unlock

Re: [R] when setting environment: target of assignment expands to non-language object

2010-04-27 Thread Michael Steven Rooney
Thanks for your help. I am making great progress, but there are still some things that are puzzling me. In the code below, I add a cat() statement to `coef<-.corExp`. Sure enough, when I run lme(), it prints. (awesome!) However, the function does not seem to be able to find the C script "spatial_f

Re: [R] when setting environment: target of assignment expands to non-language object

2010-04-27 Thread Gabor Grothendieck
You did change it. Try nlme:::corExp Also note that asNamespace("nlme") is a nicer way to refer to it. On Tue, Apr 27, 2010 at 4:32 PM, Michael Steven Rooney wrote: > Sorry, I am still not understanding this. I tried using the unlock binding > function, but the function remains unchanged after I

Re: [R] when setting environment: target of assignment expands to non-language object

2010-04-27 Thread Michael Steven Rooney
Sorry, I am still not understanding this. I tried using the unlock binding function, but the function remains unchanged after I attempt an assignment: > library(nlme) > bindingIsLocked("corExp",environment(corExp)) [1] TRUE > unlockBinding("corExp",environment(corExp)) > bindingIsLocked("corExp",e

Re: [R] when setting environment: target of assignment expands to non-language object

2010-04-26 Thread Gabor Grothendieck
See ?lockBinding On Mon, Apr 26, 2010 at 11:20 PM, Michael Steven Rooney wrote: > I tried editing the corExp function (added a line) within the nlme > environment with the following code, but it looks like my declaration did > not have any effect. I am guessing it is locked some how. Is there an

Re: [R] when setting environment: target of assignment expands to non-language object

2010-04-26 Thread Michael Steven Rooney
I tried editing the corExp function (added a line) within the nlme environment with the following code, but it looks like my declaration did not have any effect. I am guessing it is locked some how. Is there an easy way to do this or am I treading into complicated waters? (I just picked up R a year

Re: [R] when setting environment: target of assignment expands to non-language object

2010-04-26 Thread Michael Steven Rooney
Thanks. How do I make my function visible to others? Will assignInNamespace do that? On Mon, Apr 26, 2010 at 10:23 PM, Gabor Grothendieck < ggrothendi...@gmail.com> wrote: > See ?assignInNamespace > > On Mon, Apr 26, 2010 at 9:49 PM, Michael Steven Rooney > wrote: > > Hi, > > > > I am trying to

Re: [R] when setting environment: target of assignment expands to non-language object

2010-04-26 Thread Gabor Grothendieck
See ?assignInNamespace On Mon, Apr 26, 2010 at 9:49 PM, Michael Steven Rooney wrote: > Hi, > > I am trying to place my own functions in the nlme environment: > > The following statement works: > > environment(coef.corSPT) <- environment(getS3method("coef","corSpatial")) > > but this one returns a

Re: [R] when setting environment: target of assignment expands to non-language object

2010-04-26 Thread Duncan Murdoch
Michael Steven Rooney wrote: Hi, I am trying to place my own functions in the nlme environment: I'm not that does what you want. It doesn't place your function in the environment, it attaches the environment to your function. The difference is that other functions won't see yours, but y

[R] when setting environment: target of assignment expands to non-language object

2010-04-26 Thread Michael Steven Rooney
Hi, I am trying to place my own functions in the nlme environment: The following statement works: environment(coef.corSPT) <- environment(getS3method("coef","corSpatial")) but this one returns an error: environment(get("coef<-.corSPT")) <- environment(getS3method("coef<-","corSpatial")) Error