[R] Sldf command returns negative value for date

Sneha Bishnoi sneha.bishnoi at gmail.com
Thu Aug 14 21:47:59 CEST 2014


Hi All!

I am trying to increment date column of data frame so as to merge it with
another data frame using sqldf:
my query is :
merge<-sqldf("select m.* ,e.* from mdata as m left join event as e on
date(m.Datest,'+1 day')=e.Start")

The query returns null for all columns related to event table.
When I investigated further with query :
sqldf("select date(Datest,'+1 day')") from eventflight;")
 gives me -ve valued dates like : -4671-02-15

However this works:
sqldf("select date(('2009-05-01'),'+1')")

Dataframes are as follows:
mdata :
LOS Arrivals BookRange   Datest
 1     1283       0-4            2009-05-01
 1     1650       0-4            2009-05-08
 1     1302       5-9            2009-05-15

event:
 Event.Name  Event.location          Start           End
 Birthday        Texas (US)           2009-05-02    2009-05-03
 Anni              Texas (US)          2009-05-09     2009-01-11

What am I doing wrong?

Thanks in advance
SB

	[[alternative HTML version deleted]]



More information about the R-help mailing list