Skip to content

creating table of averages

4 messages · Adam D. I. Kramer, Duncan Murdoch, Lawrence Hanser

#
Maybe something like this:

by(df[,c(77,81,86,90,94,98,101,106)],df$category,apply,2,mean)

...which would then need to be reformatted into a data frame (there is
probably an easy way to do this which I don't know).

aggregate seems like a more reasonable choice, but the function for
aggregate must return scalars, not rows...tapply doesn't take data.frame
inputs. Maybe someone else has a suggestion?

--Adam
On Tue, 9 Sep 2008, Lawrence Hanser wrote:

            
#
On 9/9/2008 2:12 PM, Adam D. I. Kramer wrote:
sparseby() in the reshape package is more flexible than by(). If the 
function returns a vector with a consistent length, you'll get a 
dataframe with columns corresponding to its entries.

Duncan Murdoch