Dienstag, 15. Dezember 2009

List in DataFrame

d.frm <- data.frame(name=c("Max","Max","Max","Max","Max","Moritz","Moritz","Moritz")
,typ=c("rot","blau","grün","blau","grün","rot","rot","blau")
,anz=c(5,4,5,8,3,2,9,1) )

d.frm <- d.frm[ order(d.frm$name, -d.frm$anz),]
d.frm


Zusammenfassung wie summaryBy:

> as.data.frame( do.call("rbind", tapply( d.frm$anz, d.frm$name, summary )))

       Min. 1st Qu. Median Mean 3rd Qu. Max.
Max       3     4.0      5    5    5.0     8
Moritz    1     1.5      2    4    5.5     9

Keine Kommentare: