[R] rbind error (maybe a problem with chron package?)
Timothy W. Hilton
hilton at meteo.psu.edu
Wed Nov 24 19:33:23 CET 2010
Hello,
I have a list of data frames that I would like to combine to a single
data frame. I typically do this with:
do.call(rbind, list.of.dataframes)
This time, I get
Error in class(x) <- cl :
cannot set class to "array" unless the dimension attribute has
length > 0
I'm not sure what's happening. Each data frame has a column of chron
objects and a column of float values. Minimal example of the data
frames and the error below. If I start with a fresh R session, it
works, until I load the chron package.
I'd appreciate any suggestions!
Thanks,
Tim
--
Timothy W. Hilton
PhD Candidate, Department of Meteorology
The Pennsylvania State University
503 Walker Building, University Park, PA 16802
hilton at meteo.psu.edu
--------------------------------------------------
foo <- structure(list(date = structure(c(12052.75, 12052.875, 12053,
12053.125, 12053.25, 12053.375), .Dim = 6L, format =
structure(c("m/d/y",
"h:m:s"), .Names = c("dates", "times")), origin = structure(c(1,
1, 1970), .Names = c("month", "day", "year")), class = c("chron",
"dates", "times")), val = structure(c(NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_), .Dim = 6L)), .Names = c("date",
"val"), row.names = c(NA, 6L), class = "data.frame")
--------------------------------------------------
and an example of the error:
--------------------------------------------------
> foo
foo
date val
1 (12/31/02 18:00:00) NA
2 (12/31/02 21:00:00) NA
3 (01/01/03 00:00:00) NA
4 (01/01/03 03:00:00) NA
5 (01/01/03 06:00:00) NA
6 (01/01/03 09:00:00) NA
> rbind(foo, foo)
rbind(foo, foo)
Error in class(x) <- cl :
cannot set class to "array" unless the dimension attribute has
length > 0
--------------------------------------------------
If I start with a fresh R session, it works, until I load the chron
package:
--------------------------------------------------
$ R --vanilla
R version 2.12.0 (2010-10-15)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> foo <- structure(list(date = structure(c(12052.75, 12052.875, 12053,
+ 12053.125, 12053.25, 12053.375), .Dim = 6L, format =
structure(c("m/d/y",
+ "h:m:s"), .Names = c("dates", "times")), origin = structure(c(1,
+ 1, 1970), .Names = c("month", "day", "year")), class = c("chron",
+ "dates", "times")), val = structure(c(NA_real_, NA_real_, NA_real_,
+ NA_real_, NA_real_, NA_real_), .Dim = 6L)), .Names = c("date",
+ "val"), row.names = c(NA, 6L), class = "data.frame")
> foo
date val
1 12052.75 NA
2 12052.88 NA
3 12053.00 NA
4 12053.12 NA
5 12053.25 NA
6 12053.38 NA
> rbind(foo, foo)
date val
1 12052.75 NA
2 12052.88 NA
3 12053.00 NA
4 12053.12 NA
5 12053.25 NA
6 12053.38 NA
7 12052.75 NA
8 12052.88 NA
9 12053.00 NA
10 12053.12 NA
11 12053.25 NA
12 12053.38 NA
> library(chron)
> rbind(foo, foo)
Error in class(x) <- cl :
cannot set class to "array" unless the dimension attribute has
length > 0
More information about the R-help
mailing list