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? -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.com W. St. Paul, MN | | http://slashdot.org wilson at visi.com | <dtml-var pithy_quote> | http://linux.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "tim" == Tim Wilson <wilson at visi.com> writes: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). -- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini at u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini at scharp.org -------------- http://software.biostat.washington.edu/ ---------------- FHCRC: M: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX (my tuesday/wednesday/friday locations are completely unpredictable.) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> -----Original Message----- > 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 theresults> of TEST by GENDER so I can compare their means. > > What's the most efficient way to do this with R? > > -TimPresuming that you wish to perform a two-sample t-test on the means, you don't need to actually "split" the dataframe. You could use the formula method for t.test() by the following: t.test(df$TEST ~ df$GENDER) where df is the name of your dataframe. If you actually want to split the dataframe, see ?split. HTH. Marc -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, dear R I am dealing with my dataset with strong collinearity. I want to use the Variance Decomposition (Variance Proportion) method. There is a process in SAS called PROC REG to do it. I wonder if I can find a function in R or Splus to carry out as well. Thanks a lot! Huan -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._