[R] Aggregate to find majority level of a factor

From: Thompson, Jonathan <jonathan.thompson_at_oregonstate.edu>
Date: Thu, 31 May 2007 12:25:44 -0700


I want to use the aggregate function to summarize data by a factor (my field plots), but I want the summary to be the majority level of another factor.  

For example, given the dataframe:

Plot1     big
Plot1     big
Plot1     small
Plot2     big
Plot2     small    
Plot2     small
Plot3     small
Plot3     small
Plot3     small


My desired result would be:
Plot1 big
Plot2 small
Plot3 small

I can't seem to find a scalar function that will give me the majority level.

Thanks in advance,

Jonathan Thompson



R-help_at_stat.math.ethz.ch 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. Received on Thu 31 May 2007 - 20:20:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 May 2007 - 22:31:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.