[R] Strange Colnames
Miguel A. Arranz
maarranz at tol-project.org
Fri Feb 25 14:18:18 CET 2005
You probably want to have a look at help(embed). It might be all you need.
On Friday 25 February 2005 12:49, Georg Hoermann wrote:
> Hello world,
>
> I am trying to create a matrix of lagged time series with the
> following code fragment (I know that I can use acf-function...).
> I want to set the variable/column name to something like
> "lag 1" etc. If I try to do it I get text like
> "lagtest.lagtest.lagtest.lag 1" where does this come from?
>
> After a conversion to a data.frame it works as expected.
> What did I miss?
>
> Thanks and greetings,
>
> Georg
> ==================
>
> > lagtest <- as.ts(seq(1:100)) ;
> > for (i in 1:4) {lagtest <- cbind(lagtest,lag(ts_test,i));
>
> colnames(lagtest)[i+1]<- paste("lag",i)}
>
> > colnames(lagtest)[1]<-"H_GW";
> > colnames(lagtest)
>
> [1] "H_GW" "lagtest.lagtest.lagtest.lag 1"
> "lagtest.lagtest.lag 2"
> [4] "lagtest.lag 3" "lag 4"
>
>
> # this works...
>
> > t5 <- as.data.frame(lagtest)
> > for (i in 1:4) {names(t5)[i+1] <- paste("var",i) }
> > names(t5)
>
> [1] "H_GW" "var 1" "var 2" "var 3" "var 4"
>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list