hey, I have a huge dataset with over 300000 rows which contains data about something from 2009-2012. does anyone know how i can delete all the rows which contain data from 2009 and only have data from 2010-2012??? is there a particular function i can use on the date column so that all data from 2009 can be deleted??? -- View this message in context: http://r.789695.n4.nabble.com/deleting-data-of-a-given-date-range-tp4651272.html Sent from the R help mailing list archive at Nabble.com.
Hi> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of siddanth911 > Sent: Thursday, November 29, 2012 12:10 PM > To: r-help at r-project.org > Subject: [R] deleting data of a given date range. > > hey, > > I have a huge dataset with over 300000 rows which contains data about > something from 2009-2012. does anyone know how i can delete all the > rows which contain data from 2009 and only have data from 2010-2012??? > is there a particular function i can use on the date column so that all > data from 2009 can be deleted???It depends on structure of your data (unstated). If I presume that you have data frame and you have date in some column you can just use standard subsetting new.data <- your.data[your.data$Date > some.threshold.Date, ] Regards Petr> > > > -- > View this message in context: http://r.789695.n4.nabble.com/deleting- > data-of-a-given-date-range-tp4651272.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.
Hi, You haven't given any example dataset.? So,not sure about the format of the date column. set.seed(5) dat1<-data.frame(Date1=c("10/25/2009","11/25/2009","12/25/2009","5/10/2010","8/10/2010","9/25/2011","11/28/2011","5/3/2012"),col2=sample(1:15,8,replace=TRUE)) dat1$Date1<-as.Date(dat1$Date1,format="%m/%d/%Y") #change your date column format if it is not matching to this example. dat2<-dat1[format(dat1$Date1,"%Y")!=2009,] dat2 #?????? Date1 col2 #4 2010-05-10??? 5 #5 2010-08-10??? 2 #6 2011-09-25?? 11 #7 2011-11-28??? 8 #8 2012-05-03?? 13 A.K. ----- Original Message ----- From: siddanth911 <siddanth.srivastava at mu-sigma.com> To: r-help at r-project.org Cc: Sent: Thursday, November 29, 2012 6:10 AM Subject: [R] deleting data of a given date range. hey, I have a huge dataset with over 300000 rows which contains data about something from 2009-2012. does anyone know how i can delete all the rows which contain data from 2009 and only have data from 2010-2012??? is there a particular function i can use on the date column so that all data from 2009 can be deleted??? -- View this message in context: http://r.789695.n4.nabble.com/deleting-data-of-a-given-date-range-tp4651272.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.