posix - R POSIXct cannot be used in sql query -
i have connection brings info slq format datetime. need maintain tre time part too.
head(llammituadm$responsetime) [1] "2014-10-07 08:00:33.780" "2014-10-07 08:01:17.813" "2014-10-07 08:01:19.450" [4] "2014-10-07 08:01:34.773" "2014-10-07 08:01:54.950" "2014-10-07 08:02:08.607" > class(llammituadm$responsetime) [1] "character"
then convert datetime:
llammituadm$responsetime1<-strptime(llammituadm$responsetime, format="%y-%m-%d %h:%m:%s") > class(llammituadm$responsetime1) [1] "posixlt" "posixt" > head(llammituadm$responsetime1) [1] "2014-10-07 08:00:33 art" "2014-10-07 08:01:17 art" "2014-10-07 08:01:19 art" [4] "2014-10-07 08:01:34 art" "2014-10-07 08:01:54 art" "2014-10-07 08:02:08 art"
the need sql query , next error:
error in sqlitesendquery(conn, statement, bind.data) : raw() can applied 'raw', not 'double'
i read related posixt format. how can maintain datime , able perform query?
altought know not related query, added reproducible example:
data<-data.frame(date=c("2014-10-07 08:00:33.780","2014-10-07 08:01:17.813","2014-10-07 08:01:19.450")) > class(data$date) [1] "factor" data$date<-as.character(data$date) > class(data$date) [1] "character" data$date1<-strptime(data$date, format="%y-%m-%d %h:%m:%s") > class(data$date1) [1] "posixlt" "posixt" library(sqldf) > sqldf("select * data") error in sqlitesendquery(conn, statement, bind.data) : raw() can applied 'raw', not 'double'
posixlt list, cannot ve stored in info frame. solved with:
as.posixct(llammituadm$responsetime)
r posix
No comments:
Post a Comment