Re: [R] find most repeated item from column in dataframe

2010-08-24 Thread Marc Schwartz
How about this approach, using aggregate(): > DF StandID PlotNum HerbNum Woody 1 001 1 1low 2 001 2 2 medium 3 001 3 1low 4 001 4 3low 5 001 5 1 high 6 001 6 2 medium 7 002

Re: [R] find most repeated item from column in dataframe

2010-08-24 Thread Peter Alspach
Tena koe Randy If your dataframe is called randy, then the following seems to work: aggregate(randy[,-(1:2)], list(randy[,1]), function(x) {tt <- table(x); names(tt)[which.max(tt)]}) HTH Peter Alspach > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun.

Re: [R] find most repeated item from column in dataframe

2010-08-24 Thread Bill.Venables
Do you expect this to be easy? It may be, but I can't see a particularly graceful way to do it. Here is one possible solution. > dat StandID PlotNum HerbNum Woody 1 001 1 1low 2 001 2 2 medium 3 001 3 1low 4 001 4 3