[R] select subset of data according to date range

Jim Lemon jim at bitwrit.com.au
Sat May 1 09:48:56 CEST 2010


On 05/01/2010 02:55 PM, Carol Gao wrote:
> Dear R lists,
> ...
> Would anyone help me with setting data frames according to the date?
> ...
> my data looks like above, but definitely with more rows. Now I want a data
> frame with only "2008-12-02" in the first part of the 8th variable---Time.
>
Hi Carol,
I would do something like this:

my.data.frame[format(my.data.frame$Time,"%Y-%m-%d") == "2008-12-02",]

although there may be a better way by extracting only the day from the 
Time field.

Jim



More information about the R-help mailing list