# [R] Multiple frequencies

Douglas Bates bates at stat.wisc.edu
Wed Apr 24 19:51:03 CEST 2002

```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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```