我使用dplyr将rql表加载到tbl(rr是我的数据库连接):
s_log=rr%>%tbl("s_log")
然后提取三列并将它们放入一个新的tbl:
id_date_amount=s_log%>%select(id,created_at,amount)
当我跑头(id_date_amount)时,它正常工作:
id created_at amount
1 34101 2016-07-20 10:41:23 19750
2 11426 2016-07-20 10:38:15 19750
3 26694 2016-07-20 10:38:18 49750
4 25656 2016-07-20 10:42:05 49750
5 23987 2016-07-20 10:40:31 19750
6 24564 2016-07-20 10:38:35 19750
现在,我需要以仅包含过去21天的方式过滤id_date_amount:
filtered_ADP=subset(id_date_payment,as.Date('2016-08-22')- as.Date(created_at) > 0 & as.Date('2016-08-22')- as.Date(created_at)<=21)
我收到以下错误:
Error in as.Date(created_at) : object 'created_at' not found
我认为这是因为我本地没有id_date_payment,但我如何塑造该子集以将其发送到id_date_payment并取回结果?
我尝试使用deployer :: filter:
id_date_amount=id_date_amount %>% filter( as.Date('2016-08-22') - as.Date(created_at) > 0 & as.Date('2016-08-22')- as.Date(created_at)<=21 )
但是我收到了这个错误:
Error in postgresqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not Retrieve the result : ERROR: syntax error at or near "AS"
LINE 3: WHERE "status" = 'success' AND AS.DATE('2016-08-22') - AS.DA...
^
)