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

Brett Magill bmagill at earthlink.net
Thu Dec 19 15:40:04 CET 2002


I think my dstats function does what you want, if I understand you coorrectly.
 You could apply it over rows or columns:

  http://home.earthlink.net/~bmagill/MyMisc.html

It is there along with several other functions.



On Thu, 19 Dec 2002 11:18:25 +1000 Alexander.Herr at csiro.au wrote:

> Thanks Uwe,
> Can't seem to get your formula to work...
> I should have made this clearer. I am after a
> listing of the number of NAs
> and Valid Ns (or total N)for export to csv,eg:
> Variable, mean, Missing Values, Valid N
> test,	6.00000,2,18
> bummer,5.44444,1,19
> 
> from:
> 
> x 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
> 
> 
> 	[[alternate HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>




More information about the R-help mailing list