(I think this is probably appropriate for r-devel -- if my diagnosis
is correct, that is)
I have a script that I run infrequently (i.e., quarterly) that has
been working for several years. I re-ran it this morning for the
first time since updating R from 2.6.2 to 2.7.0, and encountered an
error.
I found a simple example that shows the problem:
> as.POSIXct( I( '2008-01-01' ) )
Error in as.POSIXlt.default(x, tz, ...) :
do not know how to convert 'x' to class
"POSIXlt">
> traceback()
6: stop(gettextf("do not know how to convert '%s' to class
\"POSIXlt\"",
deparse(substitute(x))))
5: as.POSIXlt.default(x, tz, ...)
4: as.POSIXlt(x, tz, ...)
3: as.POSIXct(as.POSIXlt(x, tz, ...), tz, ...)
2: as.POSIXct.default(I("2008-01-01"))
1: as.POSIXct(I("2008-01-01"))
> class( I('2008-01-01') )
[1] "AsIs"> is.character( I('2008-01-01') )
[1] TRUE
It looks to me as though as.POSIXlt() does not recognize the object
as being also a character object
because it calls as.POSIXlt.default() instead of as.POSIXlt.character().
> sessionInfo()
R version 2.7.0 (2008-04-22)
powerpc-apple-darwin8.10.1
locale:
C
attached base packages:
[1] utils stats graphics grDevices methods base
I have done some searching in r-help, r-devel, and NEWS through 2.8
Series News and not found anything that I recognized as either a fix
or an indication this is intended behavior. (Doesn't mean it isn't
there, of course...)
By way of background, I sometimes use the class "AsIs" for the reason
described in?AsIs, i.e.,
"Protecting an object by enclosing it in 'I()' in a call to
'data.frame' inhibits the conversion of character vectors to
factors..."
and that's what led to this discovery.
Thanks
-Don
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062