R's summary
function works really well on a dataframe, giving, for example:
> summary(fred)
sum.count count sum value
Min. : 1.000 Min. : 1.0 Min. : 1 Min. : 0.00
1st Qu.: 1.000 1st Qu.: 6.0 1st Qu.: 7 1st Qu.:35.82
Median : 1.067 Median : 9.0 Median : 10 Median :42.17
Mean : 1.238 Mean : 497.1 Mean : 6120 Mean :43.44
3rd Qu.: 1.200 3rd Qu.: 35.0 3rd Qu.: 40 3rd Qu.:51.31
Max. :40.687 Max. :64425.0 Max. :2621278 Max. :75.95
What I'd like to do is modify the function so it also gives, after 'Mean', an entry for the standard deviation, the kurtosis and the skew.
What's the best way to do this? I've researched this a bit, and adding a function with a method doesn't work for me:
> summary.class <- function(x)
{
return(sd(x))
}
The above is just ignored. I suppose that I need to understand how to define all classes to return.
How about using already existing solutions from the
psych
package?