Skip to content
Prev 243738 / 398503 Next

Help summarizing R data frame

Here are some examples with tapply, aggregate, ddply:

x <- read.table("clipboard", head=TRUE)

with(x, tapply(quantity, identifier, sum))

aggregate(x$quantity, by=list(x$identifier), sum)

aggregate(quantity ~ identifier, data = x, sum)

library(plyr)
ddply(x, .(identifier), summarise, quantity=sum(quantity))

HTH
Patrick

Am 02.12.2010 17:24, schrieb chris99: