[R] remove data frame from list of data frames

2010-11-07 Thread Matthew Finkbeiner
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

Re: [R] remove data frame from list of data frames

2010-11-07 Thread jim holtman
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

Re: [R] remove data frame from list of data frames

2010-11-07 Thread Matthew Finkbeiner
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

Re: [R] remove data frame from list of data frames

2010-11-07 Thread Henrique Dallazuanna
Try this also: ls[colSums(sapply(ls, '[[', 'Acc')) 0] On Sun, Nov 7, 2010 at 9: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-