Skip to content

Odd behavior of strptime

3 messages · partha_bagchi@hgsi.com, David Khabie-Zeitoune, Uwe Ligges

#
The strptime object is a structured list object with 9 components. (Type
"names(z)" to see the names of the individual components). You may want
to convert the strptime object to a POSIXct object using

Z = as.POSIXct(z)

This is just a vector (of the expected length).

Cheers,
Dave




-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
partha_bagchi at hgsi.com
Sent: 29 May 2003 16:05
To: r-help at stat.math.ethz.ch
Subject: [R] Odd behavior of strptime


The example from the help page for strptime has the following oddity:
+                 "02/28/92", "02/01/92")
+                 "18:21:03", "16:56:26")
[1] "1992-02-27 23:03:20" "1992-02-27 22:29:56" "1992-01-14 01:03:30" 
"1992-02-28 18:21:03" "1992-02-01 16:56:26"
[1] 9
The length is always denoted as 9.
Of course this implies that any replacement I want to do with dates etc.

always fails with the error:

Error in "[[<-.data.frame"(*tmp*, D[I], value = 
strptime(as.character(x[[D[I]]]),  : 
        replacement has 9 rows, data has 5970
_ 
platform i386-pc-mingw32
arch     i386 
os       mingw32 
system   i386, mingw32 
status 
major    1 
minor    7.0 
year     2003 
month    04 
day      16 
language R
(platform Win2000 professional)

Has anyone else encountered this?

Thanks,
Partha.


	[[alternate HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
#
partha_bagchi at hgsi.com wrote:
Hint, from ?POSIXlt:
"Class "POSIXlt" is a named list of [9] vectors representing ..."

Uwe Ligges