Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.A41.4.44.0208020836370.75822-100000@homer40.u.washington.edu>
Date: 2002-08-02T15:37:10Z
From: Thomas Lumley
Subject: extracting data from a dataframe
In-Reply-To: <20020802153146.GA3619@isis.visi.com>

On Fri, 2 Aug 2002, Tim Wilson wrote:

> Hi everyone,
>
> Here's a question about extracting data from a dataframe:
>
> Let's say I've got a dataframe with two vectors, TEST and GENDER. GENDER
> contains a 1 for males and 2 for females. I want to separate the results
> of TEST by GENDER so I can compare their means.
>
> What's the most efficient way to do this with R?
>

No guarantees of efficiency, but the easiest is
  split(df$TEST,df$GENDER)

	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._