Dinesh.hmn Dinesh.hmn - 29 days ago 25
R Question

Difference in dates using sqldf in R

I have two columns in a data frame where I need to calculate the difference in time. The data is the local PD data from open data of cities. One column is below

TimeDispatch
01/01/2011 12:00:37 AM

TimeArrive
01/01/2011 12:21:31 AM


Also the TimeArrival as a few missing values as every dispatch does not need the cops to arrive.

I am trying to find the difference using sqldf in R but it says this error

Error in sqliteSendQuery(conn, statement, bind.data) :
RAW() can only be applied to a 'raw', not a 'double'
In addition: Warning message:
In sqliteSendQuery(con, statement, bind.data) :
Closing result set with pending rows


Any help guys?

Answer

I actually found the answer. Just convert the difftime variable to an integer using as.integer(). I read numerous blogs and I could not find the answer anywhere so I am posting the answer for future reference

Comments