On Mon, 28 Apr 2008, Hutchinson,David [PYR] wrote:
I am getting an unanticipated result attempting to format a datetime
string
date1 <- strptime('2005 297 1030 35', '%Y %j %H%M %S') # returns
"2005-10-24 10:12:35"
date2 <- strptime('2005 297 912 35', '%Y %j %H%M %S') # returns NA
Are there any ways to adjust the format argument (e.g., '%H') to accept
one or two digit hours?
That's not the issue:
strptime('2005 297 9 12 35', '%Y %j %H %M %S')
[1] "2005-10-24 09:12:35"
The issue is that 91 is an invalid value for %H -- it reads from left to
right
strptime('2005 297 112 35', '%Y %j %H%M %S')
[1] "2005-10-24 11:02:35"
You will need to preprocess the string if you want another interpretation.
--
Brian D. Ripley, [EMAIL PROTECTED]
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.