Full_Name: Tim Keitt Version: 1.4 OS: Linux Submission from: (NULL) (129.49.19.70) I think this code in 'ts' is incorrect: if (is.matrix(data) || is.data.frame(data)) { nseries <- ncol(data) ndata <- nrow(data) dimnames(data) <- list(NULL, names) } since> x <- data.frame(matrix(rnorm(100),ncol=10)) > names(x)[1] "X1" "X2" "X3" "X4" "X5" "X6" "X7" "X8" "X9" "X10"> dimnames(x)[[1]] [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" [[2]] [1] "X1" "X2" "X3" "X4" "X5" "X6" "X7" "X8" "X9" "X10"> dimnames(x) <- list(NULL, names(x))Error in "dimnames<-.data.frame"(*tmp*, value = list(NULL, names(x))) : invalid dimnames given for data frame>Or else, "dimnames<-.data.frame" has a bug. T. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
tkeitt@ms.cc.sunysb.edu writes:> I think this code in 'ts' is incorrect: > > if (is.matrix(data) || is.data.frame(data)) { > nseries <- ncol(data) > ndata <- nrow(data) > dimnames(data) <- list(NULL, names) > }...> Or else, "dimnames<-.data.frame" has a bug.It doesn't (well, this isn't one...). A data frame must have unique rownames, so trying to set them to NULL is wrong, as you say. The fix would seem to be something like replacing the last line with if (is.null(dimnames(data))) dimnames(data) <- list(NULL, names) else dimnames(data)[[2]] <- name Did you actually get bitten by this one? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"Timothy H. Keitt" <Timothy.Keitt@stonybrook.edu> writes:> On Tue, 2002-01-29 at 15:57, Peter Dalgaard BSA wrote: > > > > Did you actually get bitten by this one? > > > > Yes. (Sorry if that wasn't clear.) In the past, I could create a > multivariate time series object by passing a dataframe to the 'ts' or > 'as.ts' functions --- that no longer works because 'ts' tries to set the > row names to NULL. Unless I'm missing something, the bug is in the 'ts' > function.You had me tempted to fix this for 1.4.1, but a) There's more to it than meets the eye. As I read the code, it cannot possibly have worked to do ts(dataframe) since we changed the internal structure of lists some time in the 0.6x series! The "obvious" fix tickled another bug whose fix tickled another, etc. b) On closer inspection, the docs don't promise that you should be able to do that. "Vector or matrix"... I wouldn't know whether anything would actually be able to work on a data frame with a "tsp" attribute. So the only option would be to insert an automatic conversion to a matrix. c) That would be a new feature, out of bounds the day before a release. The workaround is trivial anyway: ts(as.matrix(dataframe)) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 2002-01-29 at 18:01, Peter Dalgaard BSA wrote:> > You had me tempted to fix this for 1.4.1, but > > c) That would be a new feature, out of bounds the day before a > release. The workaround is trivial anyway: > ts(as.matrix(dataframe)) >Yes; that is what I ended up doing. Another solution is to make 'as.ts' generic and add: as.ts.data.frame <- function(x) ts(as.matrix(x)) (My code called 'as.ts' and I think I just forgot that it was not a generic fuction with a data.frame method.) T. -- Timothy H. Keitt Department of Ecology and Evolution State University of New York at Stony Brook Stony Brook, New York 11794 USA Phone: 631-632-1101, FAX: 631-632-7626 http://life.bio.sunysb.edu/ee/keitt/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._