"Bill Oliver" <wloliver at qwest.net> writes:
Is there a good method for dealing with missing values when using the POSIX
date-time classes?
I would like to convert character data with some missing values to dates, so
that I can calculate intervals of time. However, I'm having trouble figuring
out a good way to work with the missing values. Missing values cause
problems when converting to the POSIXct date-time class, as illustrated
below.
[1] "NA" "1992-02-27 22:29:56" "1992-01-14 01:03:30"
Error in fromchar(x) : character string is not in a standard unambiguous
format
Hrm. There would seem to be some scope for improvement there...
For now, as.POSIXct(strptime(foobar,format)) will work better. Notice
though, that it gives NA also for invalid strings and that foobar must
be a character vector so strptime(NA,format) won't work.