If you know the index letters are unique. df <- data.frame(indx = LETTERS[1:7], levels = sample(7))
ind1 <- which(df$indx == "A") ind2 <- which(df$indx == "B") df[ind1:ind2, ] Michael On Wed, Dec 7, 2011 at 6:23 AM, RaoulD <raoul.t.dso...@gmail.com> wrote: > Hi, > > I need help with selecting a set of rows from a column in a dataset, that > matches a string criteria - start and end. The dataset is : > > <variable Name> <Value> > List|Index 10 > ABC 20 > DEF 10 > GHI 50 > JKL 40 > MNO 20 > PQR 10 > > Start="DEF" > End = "MNO" > > Ideally, I would like to select the data from DEF to MNO into a new data > set. My logic is > 1) get the row number for DEF > 2) get the row number for MNO > 3) subset the rows from DEF to MNO > > Can someone please help me with the R code for this as am a little rusty. > Please let me know if you have questions. > > Thanks in advance! > Raoul > > -- > View this message in context: > http://r.789695.n4.nabble.com/Select-a-set-of-rows-based-on-a-condition-tp4168594p4168594.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. ______________________________________________ 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.