I need to join 2 tables using a Date field
> class(pagos$pseudo_1mes)
[1] "Date"
> class(pseudo_meses$pseudo_1mes)
[1] "Date"
My code is:
library(sqldf)
pagos<-sqldf("select a.*, b.mes_atras from pagos a
left join pseudo_meses b
on a.pseudo_1mes=b.pseudo_1mes")
And I get the following error and no result:
Error in asfn(rs[[i]]) : need explicit units for numeric conversion
How can I solve it? Thanks
One of my variables had class = 'difftime' instead of regular numeric because I subtracted dates. SQLDF does not work with the difftime class. What happened for me was that I had a data.table, subtracted some dates, and ended up with a difftime variable type. I converted to it to data.frame and when I did the subtraction again it was numeric.
I got the same problem. My solution is to add (method = "name__class") to the end of the command, such as:
sqldf("select * from pagos", method = "name__class")
However, it seem the format of date variable will be changed, albeit the date variable can be updated later. I think this is still a useful solution, since my purpose is to get sqldf work to solve a complex task while update a column is relatively much easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With