Thank you Jim (and others who responded off list). This does the trick for me perfectly:
ls[sapply(ls, function(x) all(x$Acc == 1))] Thanks again! Matthew On Sun, Nov 7, 2010 at 11:34 PM, jim holtman <jholt...@gmail.com> wrote: > Is this what you are asking; this accepts any dataframe that has at > least one Acc = 1; changing 'any' to 'all' means all Acc==1. Play > around and get what you need: > >> ls<- list(a,b) >> ls > [[1]] > x y Acc > 1 0.26550866 0.2059746 1 > 2 0.37212390 0.1765568 1 > 3 0.57285336 0.6870228 1 > 4 0.90820779 0.3841037 1 > 5 0.20168193 0.7698414 1 > 6 0.89838968 0.4976992 1 > 7 0.94467527 0.7176185 1 > 8 0.66079779 0.9919061 1 > 9 0.62911404 0.3800352 1 > 10 0.06178627 0.7774452 1 > > [[2]] > x y Acc > 1 0.93470523 0.4820801 0 > 2 0.21214252 0.5995658 0 > 3 0.65167377 0.4935413 0 > 4 0.12555510 0.1862176 0 > 5 0.26722067 0.8273733 0 > 6 0.38611409 0.6684667 0 > 7 0.01339033 0.7942399 0 > 8 0.38238796 0.1079436 0 > 9 0.86969085 0.7237109 0 > 10 0.34034900 0.4112744 0 > >> sapply(ls, function(x) any(x$Acc == 1)) > [1] TRUE FALSE >> ls[sapply(ls, function(x) any(x$Acc == 1))] > [[1]] > x y Acc > 1 0.26550866 0.2059746 1 > 2 0.37212390 0.1765568 1 > 3 0.57285336 0.6870228 1 > 4 0.90820779 0.3841037 1 > 5 0.20168193 0.7698414 1 > 6 0.89838968 0.4976992 1 > 7 0.94467527 0.7176185 1 > 8 0.66079779 0.9919061 1 > 9 0.62911404 0.3800352 1 > 10 0.06178627 0.7774452 1 > >> > > On Sun, Nov 7, 2010 at 6:07 AM, Matthew Finkbeiner > <matthew.finkbei...@mq.edu.au> wrote: >> I have a list of data frames like this: >> >> a<- data.frame(x=runif(10), y = runif(10), Acc = 1) >> b<- data.frame(x=runif(10), y = runif(10), Acc = 0) >> ls<- list(a,b) >> >> and I want to remove the data frames from ls that have Acc values other than >> 1. >> >> How do I do that? >> >> Thanks for any help! >> >> Matthew >> >> ______________________________________________ >> 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. >> > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem that you are trying to solve? > ______________________________________________ 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.