weighted means by group and column
问题 I wish to obtain weighted means by group for each of several (actually about 60) columns. This question is very similar to: repeatedly applying ave for computing group means in a data frame just asked. I have come up with two ways to obtain the weighted means so far: use a separate sapply statement for each column place an sapply statement inside a for-loop However, I feel there must be a way to insert an apply statement inside the sapply statement or vice versa, thereby eliminating the for