[Rd] as.matrix.data.frame() warning for POSIXt columns

From: David Brahm <brahm_at_alum.mit.edu>
Date: Wed 21 Jul 2004 - 09:36:16 EST

as.matrix.data.frame() issues a spurious warning for POSIXt columns in R-1.9.1:

R> x <- data.frame(date=as.POSIXct("2004-07-20")) R> as.matrix(x)

   1 "2004-07-20"
   Warning message: longer object length is not a multiple of shorter    object length in: cl == c("Date", "POSIXct", "POSIXlt")

This bug also affects write.table(x), which uses as.matrix.data.frame(x). It arises because the function is comparing the column class, which is a vector of length 2, to a vector of possible values of length 3, using == instead of %in%.

It was discussed in R-help on May 24,2004 by Don MacQueen <macq@llnl.gov> and Brian Ripley <ripley@stats.ox.ac.uk>, where Brian Ripley said:   BDR> The Warning is wrong, though, and will be fixed. but it is still there as of R-patched_2004-07-20.

The following patch to R-1.9.1/src/library/base/R/dataframe.R ought to do it: agate> diff dataframe.R dataframe.new.R 1044c1044
< any(cl == c("Date", "POSIXct", "POSIXlt"))))


> any(cl %in% c("Date", "POSIXct", "POSIXlt"))))
-- -- David Brahm (brahm@alum.mit.edu) ______________________________________________ R-devel@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
Received on Wed Jul 21 09:44:05 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 08:59:11 EST