[R] Why is there error in as.POSIXlt.character when using strftime()?
C W
tmr@g11 @end|ng |rom gm@||@com
Sat Feb 2 04:45:44 CET 2019
Dear R community,
I am working with dates. And I get the following error:
> strftime(dat[20], format="%H:%M")
Error in as.POSIXlt.character(as.character(x), ...) :
character string is not in a standard unambiguous format
Here's the original data:
dat <- structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 15L, 16L, 17L, 18L, 19L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 20L,
21L, 22L), .Label = c("7/12/15 11:32", "7/12/15 11:42", "7/12/15 12:17",
"7/12/15 12:31", "7/12/15 12:50", "7/12/15 14:10", "7/12/15 14:19",
"7/12/15 14:59", "7/12/15 15:57", "7/12/15 16:00", "7/12/15 16:46",
"7/12/15 16:51", "7/12/15 17:35", "7/12/15 17:59", "7/12/15 18:17",
"7/12/15 19:07", "7/12/15 19:08", "7/12/15 19:31", "7/12/15 21:21",
"7/13/15 10:01", "7/13/15 10:03", "7/13/15 10:05", "7/13/15 6:00",
"7/13/15 6:20", "7/13/15 6:37", "7/13/15 6:40", "7/13/15 6:46",
"7/13/15 7:20", "7/13/15 7:47", "7/13/15 7:50", "7/13/15 7:54",
"7/13/15 8:11", "7/13/15 8:23", "7/13/15 8:31", "7/13/15 8:33",
"7/13/15 8:43", "7/13/15 9:04", "7/13/15 9:09", "7/13/15 9:30",
"7/13/15 9:59"), class = "factor")
It seems like things work fine for the first 19 elements,
> strftime(dat[1:19], format="%H:%M")
[1] "11:32" "11:42" "12:17" "12:31" "12:50" "14:10" "14:19" "14:59"
[9] "15:57" "16:00" "16:46" "16:51" "17:35" "17:59" "18:17" "19:07"
[17] "19:08" "19:31" "21:21"
But why not element 20 and on? They *look* the same to me.
What is going on?
Thanks very much!
[[alternative HTML version deleted]]
More information about the R-help
mailing list