[R] when setting environment: target of assignment expands to non-language object
Gabor Grothendieck
ggrothendieck at gmail.com
Tue Apr 27 05:25:03 CEST 2010
See ?lockBinding
On Mon, Apr 26, 2010 at 11:20 PM, Michael Steven Rooney
<michael.s.rooney at gmail.com> 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 easy
> way to do this or am I treading into complicated waters? (I just picked up R
> a year ago, and I don't have any experience in development. Willing to
> learn.)
>
>> assignInNamespace("corExp",
> + function (value = numeric(0), form = ~1, nugget = FALSE, metric =
> c("euclidean",
> + "maximum", "manhattan"), fixed = FALSE)
> + {
> + cat("corExp\n") # I ADDED THIS LINE HERE
> + attr(value, "formula") <- form
> + attr(value, "nugget") <- nugget
> + attr(value, "metric") <- match.arg(metric)
> + attr(value, "fixed") <- fixed
> + class(value) <- c("corExp", "corSpatial", "corStruct")
> + value
> + },
> + environment(corExp))
>> corExp
> function (value = numeric(0), form = ~1, nugget = FALSE, metric =
> c("euclidean",
> "maximum", "manhattan"), fixed = FALSE)
> {
> attr(value, "formula") <- form
> attr(value, "nugget") <- nugget
> attr(value, "metric") <- match.arg(metric)
> attr(value, "fixed") <- fixed
> class(value) <- c("corExp", "corSpatial", "corStruct")
> value
> }
> <environment: namespace:nlme>
>
>
> On Mon, Apr 26, 2010 at 10:46 PM, Michael Steven Rooney
> <michael.s.rooney at gmail.com> wrote:
>>
>> 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
>> <ggrothendieck at gmail.com> wrote:
>>>
>>> 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.
>>> >
>>
>
>
More information about the R-help
mailing list