[R] converting dataframe into multiple time series
David Winsemius
dwinsemius at comcast.net
Sun Aug 24 03:45:34 CEST 2014
On Aug 23, 2014, at 5:52 PM, Bill wrote:
> Hello. Can someone suggest how to do this:
>
Do? .... what? If you are failing with a language that is not your native tongue, then perhaps trying to explain the background and then the goals in English will make the task more understandable, to both you and your audience.
> for (i in 2:length(colnames(allvar.df))) {
We need to know the structure of all.df.
> var=colnames(allvar.df)[i]
> timeSeriesName = paste(var,".time.series")
> varRef=paste(var,".df$",var)
> varDate=paste(var,".df$date")
That could be many things. Have you looked to see what it is? Offhand I would guess that it is a multi-element character vector.
> timeSeriesName <- ts(varRef,
ts takes an object-name as its first argument. A length-1 character vector, which is probably what varRef now is, is not an R name. Perhaps get(varRef) would return the object you seek.
> start = c(year(min(varDate)),month(min(varDate))),
I suspect a similar problem with not understanding R syntax will be setting you up for failure here. `varDate` is a character vector since you created it with `paste`, not an R name. R is not a macro language.
> end = c(year(max(varDate)),month(max(varDate))),
> frequency=12)
> }
>
> [[alternative HTML version deleted]]
Have you read the Posting Guide? (And have you worked through "Introduction to R"?)
>
> ______________________________________________
> 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.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list