[R] selecting rows with more than x occurrences in a given column (data type is names)

2007-03-13 Thread Mike Jasper
Despite a long search on the archives, I couldn't find how to do this. Thanks in advance for what is likely a simple issue. I have a data set where the first column is name (i.e., 'Joe Smith', 'Jane Doe', etc). The following columns are data associated with that person. I have many people with

Re: [R] selecting rows with more than x occurrences in a given column (data type is names)

2007-03-13 Thread Stephen Tucker
This isn't pretty, but should work: x - 10 # number of occurrences y - split(all.data,f=all.data$names) z - y[unlist(lapply(y,nrow))x] newdata - vector() for( k in z ) { newdata - rbind(newdata,k) } Basically I split your data frame into groups by name (into a list), then selected elements in

Re: [R] selecting rows with more than x occurrences in a given column(data type is names)

2007-03-13 Thread Dimitris Rizopoulos
try this: set.seed(123) all.data - data.frame(name = sample(c(Joe, Elen, Jane, Mike), 8, TRUE), x = rnorm(8), y = runif(8)) ## tab.nams - table(all.data$name) nams - names(tab.nams[tab.nams = 2]) all.data[all.data$name %in% nams, ] I hope it helps. Best, Dimitris Dimitris

Re: [R] selecting rows with more than x occurrences in a given column (data type is names)

2007-03-13 Thread Marc Schwartz
On Tue, 2007-03-13 at 10:38 -0400, Mike Jasper wrote: Despite a long search on the archives, I couldn't find how to do this. Thanks in advance for what is likely a simple issue. I have a data set where the first column is name (i.e., 'Joe Smith', 'Jane Doe', etc). The following columns are

Re: [R] selecting rows with more than x occurrences in a given column (data type is names)

2007-03-13 Thread Chuck Cleland
Mike Jasper wrote: Despite a long search on the archives, I couldn't find how to do this. Thanks in advance for what is likely a simple issue. I have a data set where the first column is name (i.e., 'Joe Smith', 'Jane Doe', etc). The following columns are data associated with that person. I

Re: [R] selecting rows with more than x occurrences in a given column (data type is names)

2007-03-13 Thread Marc Schwartz
On Tue, 2007-03-13 at 10:32 -0500, Marc Schwartz wrote: On Tue, 2007-03-13 at 10:38 -0400, Mike Jasper wrote: Despite a long search on the archives, I couldn't find how to do this. Thanks in advance for what is likely a simple issue. I have a data set where the first column is name

Re: [R] selecting rows with more than x occurrences in a given column(data type is names)

2007-03-13 Thread Mike Jasper
Thanks to all of you who got me the answer. The key I was missing was %in%. Had never seen it before. best. On 3/13/07, Dimitris Rizopoulos [EMAIL PROTECTED] wrote: try this: set.seed(123) all.data - data.frame(name = sample(c(Joe, Elen, Jane, Mike), 8, TRUE), x = rnorm(8), y =