[R] Odd behavior of strptime

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu May 29 17:34:17 CEST 2003


partha_bagchi at hgsi.com wrote:
> The example from the help page for strptime has the following oddity:
> 
> 
>>     dates <- c("02/27/92", "02/27/92", "01/14/92",
> 
> +                 "02/28/92", "02/01/92")
> 
>>     times <- c("23:03:20", "22:29:56", "01:03:30",
> 
> +                 "18:21:03", "16:56:26")
> 
>>     x <- paste(dates, times)
>>     z <- strptime(x, "%m/%d/%y %H:%M:%S")
>>     z
> 
> [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"
> 
>>length(z)
> 
> [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
> 
>>version
> 
>          _ 
> 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.


Hint, from ?POSIXlt:
"Class "POSIXlt" is a named list of [9] vectors representing ..."

Uwe Ligges




More information about the R-help mailing list