[R] summary stats including NA's into new dataframe

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Dec 18 08:33:03 CET 2002


Alexander.Herr at csiro.au wrote:
> List,
> 
> I am trying to extract summary statistics from a data frame with several
> variables (and NAs) into a dataframe with the columns: Variablename (ie the
> colnames of original data), mean, stdev, max, min, Valid N, Missing Values.
> 
> Extracting the statistics is straightforward using stack and aggregate.
> However, I haven't succeeded in obtaining the number of Missing Values. I
> can extract these from describe (Hmisc library), but surely there is a
> simpler way similar to obtaining the mean using aggregate?

The similar way is:

aggregate(......., function(x) sum(is.na(x)))

Uwe Ligges

> Suggestions are much appreciated




More information about the R-help mailing list