I know the `quantcut' function in the gregmisc package, and using it, I'm able to use functions like aggregate to compute the mean or sd() in each quartile. What if I have a data frame containing x and y, and I want to make quartiles by x, but then compute sum x / sum y in each quartile? How does one persuade aggregate to do this? Thanks, -- Ajay Shah Consultant ajayshah at mayin.org Department of Economic Affairs http://www.mayin.org/ajayshah Ministry of Finance, New Delhi
Check out ?by For example, data(iris) by(iris, quantcut(iris[,1]), function(x) sum(x[,1]/x[,2])) -- From: Ajay Shah <ajayshah at mayin.org> I know the `quantcut' function in the gregmisc package, and using it, I'm able to use functions like aggregate to compute the mean or sd() in each quartile. What if I have a data frame containing x and y, and I want to make quartiles by x, but then compute sum x / sum y in each quartile? How does one persuade aggregate to do this?