R中使用sqldf的日期差异 [英] Difference in dates using sqldf in R
问题描述
我在数据框中有两列,我需要计算时间差.数据是来自城市开放数据的本地PD数据.下方是一列
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
TimeArrival还缺少一些值,因为每次调度都不需要警察到达.
Also the TimeArrival as a few missing values as every dispatch does not need the cops to arrive.
我正在尝试在R中使用sqldf来发现差异,但是它显示了此错误
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
有没有帮助的人?
推荐答案
我实际上找到了答案.只需使用 as.integer()
将difftime变量转换为整数.我读了许多博客,但找不到答案,所以我将答案发布以供将来参考
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
这篇关于R中使用sqldf的日期差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!