[R] Coercing a dataframe column to datetime
richard.kittler@amd.com
richard.kittler at amd.com
Mon Jun 14 20:37:08 CEST 2004
I am trying to coerce a data frame column from character to datetime using strptime but keep getting an error because the length of the coerced object is always 9. What am I doing wrong here:
.................................................................
> ds <- cbind(1:2, c("02/27/92 23:03:20", "02/27/92 22:29:56")); ds
[,1] [,2]
[1,] "1" "02/27/92 23:03:20"
[2,] "2" "02/27/92 22:29:56"
>
> q <- strptime(ds[,2], "%m/%d/%y %H:%M:%S"); q
[1] "1992-02-27 23:03:20" "1992-02-27 22:29:56"
>
> ds[,2] <- q
Error in "[<-"(`*tmp*`, , 2, value = q) : number of items to replace is not a multiple of replacement length
>
> length(q)
[1] 9
.................................................................
--Rich
Richard Kittler
AMD TDG
408-749-4099
More information about the R-help
mailing list