Skip to content
Prev 22338 / 398502 Next

extracting data from a dataframe

tim> Hi everyone,
    tim> Here's a question about extracting data from a dataframe:

    tim> Let's say I've got a dataframe with two vectors, TEST and GENDER. GENDER
    tim> contains a 1 for males and 2 for females. I want to separate the results
    tim> of TEST by GENDER so I can compare their means.

    tim> What's the most efficient way to do this with R?

something like:

lapply(split(df$TEST,df$GENDER),mean)

?
(where "df" is the data.frame).