[R] How to count rows with a condition
dwinsemius at comcast.net
Wed Oct 17 22:25:04 CEST 2012
On Oct 17, 2012, at 5:44 AM, fxen3k wrote:
> I have a dataset called "data". There is one row called "ac_name".
> names in this column appear very often, some less.
> What I want is to filter this dataset with the following condition:
> Exclude the names, which appear more than five times. (example:
> House A
> appears 8 times ==> exclude it; House B appears 5 times ==> include
> it etc.)
> In the end, I want to have the old "data" dataset excluding the rows
> the above mentioned condition and another list with all the names
> which have
> been excluded.
data[ ave(data$ac_name, data$ac_name, length) <= 5, ] # all with 5 or
David Winsemius, MD
Alameda, CA, USA
More information about the R-help