[R] Formula variable help

Kevin Burton rkevinburton at charter.net
Fri Nov 11 19:36:22 CET 2011


It seems that there is a bug in the forecast::tslm function. I have forwarded what I think is the bug (the call to get() should supply the argument 'envir=parent.frame()').

Thank you.

On Nov 11, 2011, at 12:11 PM, Joshua Wiley <jwiley.psych at gmail.com> wrote:

> Seems like it could work---can you save your script as a .txt file and
> send it as an attachment, upload it online, or make a reproducible
> example?
> 
> Cheers,
> 
> Josh
> 
> On Fri, Nov 11, 2011 at 9:52 AM,  <rkevinburton at charter.net> wrote:
>> 
>> I have an R script with the following applicable lines:
>> 
>>                xshort <- window(s, start=st, end=ed)
>> . . .
>>                xshort <- ts(xshort, frequency=1, start=1)
>> . . .
>>                m1 <- m2 <- m3 <- m4 <- m5 <- m6 <- NULL
>>                m1 <- tslm(xshort ~ trend)
>> 
>> I get an error:
>> 
>> Error in get(dataname) : object 'xshort' not found
>> 
>> When I do traceback() I get:
>> 
>> 3: get(dataname)
>> 2: tslm(xshort ~ trend) at #19
>> 1: model.cross.validation(l[["MEN"]]$series)
>> 
>> Which points to the call to tslm above.  Since I am not supply 'data' to
>> the tslm call (in the forecast package),, I am assuming that the code is
>> dying here (in tslm):
>> 
>>     if (missing(data)) {
>>         dataname <- as.character(formula)[2]
>>         x <- get(dataname)
>>         data <- data.frame(x)
>>         colnames(data) <- dataname
>>     }
>> 
>> Any ideas what is failing?
>> 
>> Kevin
>> 
>>        [[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.
>> 
> 
> 
> 
> -- 
> Joshua Wiley
> Ph.D. Student, Health Psychology
> Programmer Analyst II, ATS Statistical Consulting Group
> University of California, Los Angeles
> https://joshuawiley.com/



More information about the R-help mailing list