Stratified data summaries

4 messages Options
Embed this post
Permalink
Hayes, Rachel M

Stratified data summaries

Reply Threaded More More options
Print post
Permalink
Hi All,

 

I'm trying to automate a data summary using summary or describe from the
HMisc package.  I want to stratify my data set by patient_type.  I was
hoping to do something like:

 

Describe(myDataFrame ~ patient_type)

 

I can create data subsets and run the describe function one at a time,
but there's got to be a better way.  Any suggestions?

 

Rachel


        [[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.
Dylan Beaudette

Re: Stratified data summaries

Reply Threaded More More options
Print post
Permalink
Hi, the plyr package is your friend.

Here is a tutorial on a related subject:

http://casoilresource.lawr.ucdavis.edu/drupal/node/836

cheers,
Dylan

On Thursday 09 July 2009, Hayes, Rachel M wrote:

> Hi All,
>
>
>
> I'm trying to automate a data summary using summary or describe from the
> HMisc package.  I want to stratify my data set by patient_type.  I was
> hoping to do something like:
>
>
>
> Describe(myDataFrame ~ patient_type)
>
>
>
> I can create data subsets and run the describe function one at a time,
> but there's got to be a better way.  Any suggestions?
>
>
>
> Rachel
>
>
> [[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.



--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

______________________________________________
[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.
David Winsemius

Re: Stratified data summaries

Reply Threaded More More options
Print post
Permalink
In reply to this post by Hayes, Rachel M

On Jul 9, 2009, at 6:52 PM, Hayes, Rachel M wrote:
> I'm trying to automate a data summary using summary or describe from  
> the
> HMisc package.  I want to stratify my data set by patient_type.  I was
> hoping to do something like:
>
>
>
> Describe(myDataFrame ~ patient_type)
>

> by(myDataFrame, patient_type, describe)


Or:

Describe.by <- function(.df, .categ) { by( .df, .categ, describe) }

>
>
> I can create data subsets and run the describe function one at a time,
> but there's got to be a better way.  Any suggestions?
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
[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.
David Freedman

Re: Stratified data summaries

Reply Threaded More More options
Print post
Permalink
In reply to this post by Hayes, Rachel M
You might also want to look at the doBy package - one function is summaryBy:

summaryBY(var1 + var2 ~ patient_type, data=d, FUN=summary)

david freedman
Hayes, Rachel M wrote:
Hi All,

 

I'm trying to automate a data summary using summary or describe from the
HMisc package.  I want to stratify my data set by patient_type.  I was
hoping to do something like:

 

Describe(myDataFrame ~ patient_type)

 

I can create data subsets and run the describe function one at a time,
but there's got to be a better way.  Any suggestions?

 

Rachel


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.