I have loaded a sql table to a tbl using dplyr (rr is my db connection) :
s_log=rr%>%tbl("s_log")
then extracted three columns and put them in a new tbl :
id_date_amount=s_log%>%select(id,created_at,amount)
when i run head (id_date_amount) it works properly:
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
now , i need to filter the id_date_amount in a way that it only contains the past 21 days:
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)
i get the following error:
Error in as.Date(created_at) : object 'created_at' not found
i think that's because i don't have id_date_payment locally , but how can i shape that subset to sent it to id_date_payment and get back the results?
i tried using 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 )
but i get this error :
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...
^
)