[R] How to filter datetime from a dataframe

arun smartpink111 at yahoo.com
Wed Jul 25 14:45:39 CEST 2012


Hi,
Try this:

date1<-c("26/Jun/2012","27/Jun/2012","28/Jun/2012","29/Jun/2012","01/Jul/2012","02/Jul/2012","03/Jul/2012","04/Jul/2012", "15/Jul/2012","20/Jul/2012","05/Jul/2012","06/Jul/2012","07/May/2012","08/Jul/2012","09/Jul/2012")
date2<-as.Date(date1,format="%d/%b/%Y")
dat2<-data.frame(var1=sample(1:15,15,replace=T),date2)
subset(dat2,dat2$date2>"2012-07-01"&dat2$date2<"2012-07-10")
   var1      date2
6     3 2012-07-02
7    10 2012-07-03
8    14 2012-07-04
11   10 2012-07-05
12   14 2012-07-06
14   14 2012-07-08
15   11 2012-07-09

A.K.



----- Original Message -----
From: purushothaman <purushothaman.b at ge.com>
To: r-help at r-project.org
Cc: 
Sent: Wednesday, July 25, 2012 3:05 AM
Subject: [R] How to filter datetime from a dataframe

I have one month data in a dataframe..

I need to filter data based on start date and end date 
Ex: Start date :- 01/Jul/2012 and End date :- 10/Jul/2012 

Please help me to find the solution



--
View this message in context: http://r.789695.n4.nabble.com/How-to-filter-datetime-from-a-dataframe-tp4637721.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list