search for: aggdf

Displaying 1 result from an estimated 1 matches for "aggdf".

Did you mean: agedf
2011 Sep 26
1
producing an aggregate table of top 3 by cost
...ema", 4), rep("itemb", 2), rep("itemc", 1), rep("itemc", 3)) cost <- round (rnorm(30, mean = 100, sd = 30), 2) DF <- data.frame(group, product, cost) agglist <- list(DF$product, DF$group) col1<- aggregate(DF [,3], by = agglist, sum) col2<- aggregate(aggDF [,3], by = agglist, length) (table <- cbind(col1, col2))   My question would be, how about if you wanted a table that retained only the top 1 product (e.g., item c for group 2) by group... or for that matter the top n=2 or n=3 or n=5?  While with this example DF the answer would be easy to find,...