[R] summary per group

Johannes Radinger JRadinger at gmx.at
Mon Jan 2 14:08:10 CET 2012


Hello,

I know that it'll be quite easy to do what I want but somehow I am lost as I am new to R. I want to get summary results arranged by groups. In detail
I'd like get the number (levels) of Species per Family like for this dataset:

SPEC <- factor(c("a","a","b","b","c","c","c","d","e","e","e","e"))
FAM <- factor(c("A","A","A","A","B","B","B","C","C","C","C","C"))
df <- data.frame(SPEC,FAM)

I tried tapply(SPEC, FAM, nlevels).. but it is not the result I am looking for...

What is the easiest way to do that? Do I have to rearrange the dataset?

Best regards and Happy New Year!

Johannes

--



More information about the R-help mailing list