Michael Steven Rooney
2010-Apr-27 01:49 UTC
[R] when setting environment: target of assignment expands to non-language object
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 in environment(get("coef<-.corSPT")) <- environment(getS3method("coef<-", : target of assignment expands to non-language object What should I do? Thanks. Mike [[alternative HTML version deleted]]
Duncan Murdoch
2010-Apr-27 02:21 UTC
[R] when setting environment: target of assignment expands to non-language object
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 your function will see whatever is in that 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 in environment(get("coef<-.corSPT")) <- > environment(getS3method("coef<-", : > target of assignment expands to non-language object > > What should I do? >If you want to change the coef<-.corSPT object, use backquotes to treat it as a name: environment(`coef<-.corSPT`) <- ... Duncan Murdoch> Thanks. > > Mike > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Gabor Grothendieck
2010-Apr-27 02:23 UTC
[R] when setting environment: target of assignment expands to non-language object
See ?assignInNamespace On Mon, Apr 26, 2010 at 9:49 PM, Michael Steven Rooney <michael.s.rooney at gmail.com> 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 an error: > > environment(get("coef<-.corSPT")) <- > environment(getS3method("coef<-","corSpatial")) > Error in environment(get("coef<-.corSPT")) <- > environment(getS3method("coef<-", ?: > ?target of assignment expands to non-language object > > What should I do? > > Thanks. > > Mike > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >