[Rd] Re: write.table() fails for POSIXlt class and NAs in another variable (PR#3242)

ligges at statistik.uni-dortmund.de ligges at statistik.uni-dortmund.de
Thu Jun 12 10:29:29 MEST 2003


Uwe Ligges wrote:

> Consider the following data.frame:
> 
>  > testdata
>          date nothing
>  1 1991-12-31      NA
>  2 1991-12-31      NA
> 
> where date is of class POSIXlt. For easy reproducibility:
> 
>  "testdata" <- structure(list(date = structure(list(sec = c(0, 0),
>  min = c(0, 0), hour = c(0, 0), mday = c(31, 31), mon = c(11, 11),
>  year = c(91, 91), wday = c(2, 2), yday = c(364, 364),
>  isdst = c(0, 0)), .Names = c("sec", "min", "hour", "mday", "mon",
>  "year", "wday", "yday", "isdst"), class = c("POSIXt", "POSIXlt")),
>  nothing = c(NA, NA)), .Names = c("date", "nothing"),
>  row.names = c("1", "2"), class = "data.frame")
> 
> 
> write.table() fails in this case:
> 
>  write.table(testdata, file="test.dat")
> Error in as.matrix.data.frame(x) : dim<- length of dims do not match the 
> length of object
> 
> and
> 
>  write.table(testdata[1,], file="test.dat")
> Error in as.matrix.data.frame(x) : length of dimnames[2] not equal to 
> array extent
> 
> I don't have the time to debug it right now, hence filing it as a bug 
> report.

OK, after having spent a few minutes I do not have:
The bug is obviously in as.matrix.data.frame() as the error message had
told me (I should have seen this yesterday at once). I cannot really 
suggest anything, since some of the constructs within 
as.matrix.data.frame() seem to be rather strange. For sure, at
least some of those are intended, but unfortunately the code lacks of
comments.

Uwe Ligges



> Uwe Ligges
> 
>          _
> platform i386-pc-mingw32
> arch     i386
> os       mingw32        (Windows NT 4.0)
> system   i386, mingw32
> status   Beta
> major    1
> minor    7.1
> year     2003
> month    06
> day      11
> language R
>



More information about the R-devel mailing list