Re: [R] Odp: mean and sd with number of values?

From: Martin Kaffanke <technik_at_roomandspace.com>
Date: Thu, 06 Mar 2008 18:05:03 +0100

Am Donnerstag, den 06.03.2008, 17:47 +0100 schrieb Petr PIKAL:
> Hi
>
> r-help-bounces@r-project.org napsal dne 06.03.2008 17:41:06:
>
> > Hi there,
> >
> > When i do
> >
> > mean(fl[1:20], na.rm=T)
>
> e.g.
>
> sum(!is.na(fl[1:20]))

This seems to give me a sum of all the items.

But I'd like to have it per column.

> mean(fl[1:20])

           aids angststoer autismus bauchspduekrebs prostata

     -0.7474884 -1.0475500 -0.6267267 NA -1.7318179

        fraudep manndep hautkrebs herzinfarkt leukaemie

     -1.2919841 -1.5124280 -0.3202036 -0.8246589 0.7550549

    lungenkrebs manischdepresiv magenkrebs magersucht mannmagsucht

     -1.2451753 -1.9726160 1.4548394 -0.6242250 NA

    osteoporose panik schizophrenie schlaganfall zwangsstoer

     -1.7974270 NA -1.8634089 NA -1.5056106

> mean(fl[1:20], na.rm=T)

           aids angststoer autismus bauchspduekrebs prostata

     -0.7474884 -1.0475500 -0.6267267 1.2168804 -1.7318179

        fraudep manndep hautkrebs herzinfarkt leukaemie

     -1.2919841 -1.5124280 -0.3202036 -0.8246589 0.7550549

    lungenkrebs manischdepresiv magenkrebs magersucht mannmagsucht

     -1.2451753 -1.9726160 1.4548394 -0.6242250 -0.3765245

    osteoporose panik schizophrenie schlaganfall zwangsstoer

     -1.7974270 -1.2328361 -1.8634089 -1.7165059 -1.5056106

> sum(!is.na(fl[1:20]))
[1] 892

So I'd like to have it like the mean, to see how many data is calculated by na.rm=T per column?

Thanks,
Martin



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Received on Thu 06 Mar 2008 - 17:07:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 07 Mar 2008 - 14:30:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive