From: Gabor Grothendieck <ggrothendieck_at_gmail.com>

Date: Mon 06 Jun 2005 - 03:57:13 EST

R-help@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 Received on Mon Jun 06 04:03:59 2005

Date: Mon 06 Jun 2005 - 03:57:13 EST

On 6/5/05, Andy Bunn <abunn@whrc.org> wrote:

> > some_df[1, ] is actually a data frame: see ?"[.data.frame". It's hard to

*> > see what else it could be, as columns of a data frame are of arbitrary
**> > classes.
**>
**> I see, I was confusing class and mode. However, since a list can be a ts
**> object as in this example:
**>
**> R > w <- list(rnorm(10), rnorm(10))
**> R > x <- ts(w, start = 1980)
*

> R > y <- ts(rnorm(10), start = 1981)

*> R > tsp(x); tsp(y)
**> [1] 1980 1981 1
**> [1] 1981 1990 1
**> R > class(x); class(y)
**> [1] "ts"
**> [1] "ts"
**> R > mode(x); mode(y)
**> [1] "list"
**> [1] "numeric"
**> R > z <- ts.intersect(x,y)
**> Error: incorrect number of subscripts on matrix
**> R >
**>
**> What would be the easiest way to make x a mts that could be used with plot
**> or ts.intersect?
*

The correct way to do this is to create a valid ts object from the start such as any of the following:

ts(do.call(cbind, w), start = 1980) ts(cbind(w[[1]], w[[2]]), start = 1980) ts(as.data.frame(w), start = 1980) ts(data.frame(w[[1]], w[[2]]), start = 1980)

(The resulting column names may differ depending on which you use.)

If you already have an invalid object of the sort described by x in your post then the following would do:

ts(do.call(cbind, x), start = start(x), frequency = frequency(x))

although in your case frequency(x) is the default, 1, so it could be dropped.

R-help@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 Received on Mon Jun 06 04:03:59 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:32:22 EST
*