Re: [R] cbind'ing multivariate ts objects

From: Андрей Парамонов <cmr.pent_at_gmail.com>
Date: Sun, 15 Jun 2008 11:25:31 +0400

2008/6/15 Prof Brian Ripley <ripley_at_stats.ox.ac.uk>:
> Consistent with what? This is how all such combinations of matrices in R
> work, and avoids duplicate names.
>

Hm, for data.frames and matrices it works like this:

> d <- data.frame('a' = 10:20, b = 20:30, c = 30:40, d = 40:50)
> d1 <- d[c('a', 'b')]
> d2 <- d[c('c', 'd')]
> colnames(d1)

[1] "a" "b"
> colnames(d2)

[1] "c" "d"
> colnames(cbind(d1, d2))

[1] "a" "b" "c" "d"
>
> m <- as.matrix(data.frame('a' = 10:20, b = 20:30, c = 30:40, d = 40:50))
> m1 <- d[c('a', 'b')]
> m2 <- d[c('c', 'd')]
> colnames(m1)

[1] "a" "b"
> colnames(m2)

[1] "c" "d"
> colnames(cbind(m1, m2))

[1] "a" "b" "c" "d"

cbind'ing ts objects is inconsistent with that:

> t <- ts(data.frame(a = 10:20, b = 20:30, c = 30:40, d = 40:50))
> t1 <- t[, c('a', 'b')]
> t2 <- t[, c('c', 'd')]
>
> colnames(t1)
[1] "a" "b"
> colnames(t2)

[1] "c" "d"
> colnames(cbind(t1, t2))
[1] "t1.a" "t1.b" "t2.c" "t2.d"

Andrey Paramonov



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. Received on Sun 15 Jun 2008 - 07:43:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 15 Jun 2008 - 10:30:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive