How to get the descriptive statistic of the whole dataframe?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get the descriptive statistic of the whole dataframe?

Lao Meng
Hi all:
If I have a dataframe of N columns.If I wanna get the min(or max,or
mean...etc)of the whole dataframe,how to do it quickly?
What I can do is only:
min(data[,1:ncol(data)])

Any other suggestion?

Thanks!

best

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to get the descriptive statistic of the whole dataframe?

Daniel Malter
look into the *apply series of functions. In your case

apply(name.of.your.data.frame,2,min)

or

apply(name.of.your.data.frame,2,max)

will do. You can also put any summary function to your liking instead of min/max.

Best,
Daniel

Lao Meng wrote
Hi all:
If I have a dataframe of N columns.If I wanna get the min(or max,or
mean...etc)of the whole dataframe,how to do it quickly?
What I can do is only:
min(data[,1:ncol(data)])

Any other suggestion?

Thanks!

best

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to get the descriptive statistic of the whole dataframe?

PIKAL Petr
Hi

>
> look into the *apply series of functions. In your case
>
> apply(name.of.your.data.frame,2,min)
>
> or
>
> apply(name.of.your.data.frame,2,max)
>
> will do. You can also put any summary function to your liking instead of
> min/max.

And summary has its own data frame method so simply

summary(name.of.your.data.frame)

There is also fivenum function and more elaborated describe in Hmisc I
believe :-)

Regards
Petr

>
> Best,
> Daniel
>
>
> Lao Meng wrote:
> >
> > Hi all:
> > If I have a dataframe of N columns.If I wanna get the min(or max,or
> > mean...etc)of the whole dataframe,how to do it quickly?
> > What I can do is only:
> > min(data[,1:ncol(data)])
> >
> > Any other suggestion?
> >
> > Thanks!
> >
> > best
> >
> >    [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] 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.
> >
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-get-
> the-descriptive-statistic-of-the-whole-dataframe-tp3751857p3752007.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to get the descriptive statistic of the whole dataframe?

William Revelle
At 10:31 AM +0200 8/18/11, Petr PIKAL wrote:

>Hi
>
>>
>>  look into the *apply series of functions. In your case
>>
>>  apply(name.of.your.data.frame,2,min)
>>
>>  or
>>
>>  apply(name.of.your.data.frame,2,max)
>>
>>  will do. You can also put any summary function to your liking instead of
>>  min/max.
>
>And summary has its own data frame method so simply
>
>summary(name.of.your.data.frame)
>
>There is also fivenum function and more elaborated describe in Hmisc I
>believe :-)


There are at least 3 different describe functions, all useful, but
with somewhat different output

describe (psych)
describe (Hmisc)
describe (prettyR)

One of these will probably do just what you want.

Bill


>
>Regards
>Petr
>
>>
>>  Best,
>>  Daniel
>>
>>
>>  Lao Meng wrote:
>>  >
>>  > Hi all:
>>  > If I have a dataframe of N columns.If I wanna get the min(or max,or
>>  > mean...etc)of the whole dataframe,how to do it quickly?
>>  > What I can do is only:
>>  > min(data[,1:ncol(data)])
>>  >
>>  > Any other suggestion?
>>  >
>>  > Thanks!
>>  >
>>  > best
>>  >
>>  >    [[alternative HTML version deleted]]
>>  >
>>  > ______________________________________________
>  > > [hidden email] 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.
>>  >
>>
>  > --

--
William Revelle http://personality-project.org/revelle.html
Professor http://personality-project.org
Department of Psychology             http://www.wcas.northwestern.edu/psych/
Northwestern University http://www.northwestern.edu/
Use R for psychology                       http://personality-project.org/r
It is 6 minutes to midnight http://www.thebulletin.org

______________________________________________
[hidden email] 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.