Consider the following data.frame, d.
d <- data.frame(c("a","b","c","d","b","a"), c(1,4,85,3,4,1), c(7,6,2,4,15,33))
names(d) <- c("foo", "bar", "baz")
To get the colsum of d[[2]] for the rows that have d$foo == "a" I know
I can use
colSums(subset(d, d[[1]] == "a", select = 2))
But what is needed to get a list of colSums for d[[2]] for each factor
of d$foo ? Can it be done without a for loop?
Hans Ekbrand (http://sociologi.cjb.net) <hans at sociologi.cjb.net> GPG Fingerprint: 1408 C8D5 1E7D 4C9C C27E 014F 7C2C 872A 7050 614E -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : https://stat.ethz.ch/pipermail/r-help/attachments/20080318/7adf898e/attachment.bin