From ligges at statistik.uni-dortmund.de  Thu Jun 12 10:29:29 2003
From: ligges at statistik.uni-dortmund.de (ligges@statistik.uni-dortmund.de)
Date: Thu Jun 12 09:29:43 2003
Subject: [Rd] Re: write.table() fails for POSIXlt class and NAs in another
	variable (PR#3242)
Message-ID: <200306120729.h5C7TT2b025655@pubhealth.ku.dk>

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
>


[Rd] Re: write.table() fails for POSIXlt class and NAs in another variable (PR#3242)
ligges@statistik.uni-dortmund.de