Hi! I'm having a small problem with an assignment I have to do. We want to do an anova on some values, given for four different types of medicine. The different sample numbers are not identical (eg for molecule A we have 8 values, for B we have 14, etc.). What would the most elegant way of getting this info into R to do an lm be? I usually try to use data.frames but R categorically refuses to combine the values (i scan()'d them into four vectors) because their row numbers aren't identical. (even if I do check.rows = FALSE). Thanks for your help, Yannick ------------------------------------ yannick.wurm at insa-lyon.fr http://homepage.mac.com/yannickwurm/ tel: 06.16.41.71.92 icq: 22044361 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 Wed, Apr 24, 2002 at 10:11:18AM +0200, Yannick Wurm wrote:> Hi! > I'm having a small problem with an assignment I have to do. > We want to do an anova on some values, given for four > different types of medicine. The different sample numbers are > not identical (eg for molecule A we have 8 values, for B we have > 14, etc.). > What would the most elegant way of getting this info into R > to do an lm be? I usually try to use data.frames but R > categorically refuses to combine the values (i scan()'d them > into four vectors) because their row numbers aren't identical. > (even if I do check.rows = FALSE). > > Thanks for your help, > > Yannick > > ------------------------------------ > yannick.wurm at insa-lyon.fr > http://homepage.mac.com/yannickwurm/ > tel: 06.16.41.71.92 icq: 22044361 > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._It looks like a job for 'factor'... The following R command should help you to figure out how... help(factor) data(InsectSprays) help(InsectSprays) Hopin' it helps, Laurent -------------------------------------------------------------- Laurent Gautier CBS, Building 208, DTU PhD. Student D-2800 Lyngby,Denmark tel: +45 45 25 24 85 http://www.cbs.dtu.dk/laurent -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Yannick Wurm <idh at poulet.org> writes:> I'm having a small problem with an assignment I have to do.> We want to do an anova on some values, given for four > different types of medicine. The different sample numbers are not > identical (eg for molecule A we have 8 values, for B we have 14, etc.).> What would the most elegant way of getting this info into R to > do an lm be? I usually try to use data.frames but R categorically > refuses to combine the values (i scan()'d them into four vectors) > because their row numbers aren't identical. (even if I do check.rows > FALSE).Once you have the four vectors use stack to convert them to a data frame with the values all stacked in one column and a companion column of the indicators of the group.> m1 <- 1:6 > m2 <- 101:104 > m3 <- 201:205 > stack(list(m1 = m1, m2 = m2, m3 = m3))values ind 1 1 m1 2 2 m1 3 3 m1 4 4 m1 5 5 m1 6 6 m1 7 101 m2 8 102 m2 9 103 m2 10 104 m2 11 201 m3 12 202 m3 13 203 m3 14 204 m3 15 205 m3 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._