On 09/21/2009 03:55 PM, premmad wrote:
I have 70 columns and more than 400k rows .In the data date column will have values from 1900(01/01/1900) .How do i select only the data of recent two years?Help me in this regard
Hi premmad, First, find out what the two most recent dates are:
two_recent_dates<- sort(strptime(mydata$date,format="%d/%m/%Y")),TRUE)[1:2] then get the row indices of those dates. which(strptime(mydata$date,format="%d/%m/%Y") %in% two_recent_dates) then select your rows: mydata[two_recent_dates,] Jim ______________________________________________ R-help@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.