[R] Query regarding date as argument in functions - and about sqldf
Gabor Grothendieck
ggrothendieck at gmail.com
Sun May 13 01:14:23 CEST 2012
On Sat, May 12, 2012 at 6:18 PM, Shivam <shivamsingh at gmail.com> wrote:
> Hi,
>
> I have a query about sqldf, and dates in general. I couldnt find much on
> the net or on the forums, hence I am here. Here is the issue:
>
> I want to write a function that accepts 3 arguments: date1, date2 and a
> dataframe, say 'df'. Within the function, I want to populate a temp
> dataframe which essentially contains the output of the query "select * from
> df where DATE between date1 and date2". DATE is a column (of class Date)
> which will be present in the input dataframe. This is how the function will
> look like:
>
> testfun = function("date1", "date2", df){
> temp = sqldf("select * from df where DATE between 'date1' and 'date2'")
> return(temp) #not sure if I'm doing this correctly
> }
See FAQ 4 on the sqldf home page. http://sqldf.googlecode.com
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list