james perkins wrote: > Thanks a lot for that. Its the %in% I needed to work out mainly > > large didn't mean anything in particular, just that it gets quite long > with the real data. > I did mean: names = c("John", "Phil", "Robert") > > The only problem is that using the method you suggest is that I lose > the indexing, ie in the example, instead of: > > (index) Name Fave.Number > 1 John 7 > 2 Phil 14 > 3 Robert 23 > > > I end up with > > > (index) Name Fave.Number > 1 John 7 > 3 Phil 14 > 5 Robert 23 > > This isnt a problem at the moment but I guess it could be if I used > the table later in loops. Is there an easy way to re-index the table? strange. i run this simulated example, and it's ok:
d = data.frame(a=letters[rep(1:5,2)], b=letters[10:1]) d[d$a %in% letters[1:3], ] you can always add an index column: d = data.frame(index=1:dim(d)[[1]],d) vQ ______________________________________________ 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.