Dear all, let say I have following data frame:
> data.frame(x=rnorm(18), y=rep(c("a", "b", "c"), each=6))
x y
1 -1.072152537 a
2 0.382985265 a
3 0.058877377 a
4 -0.006911939 a
5 -2.355269051 a
6 -0.303095553 a
7 0.484038422 b
8 0.733928931 b
9 -1.136014346 b
10 0.503552090 b
11 1.708609658 b
12 -0.294599403 b
13 1.239308497 c
14 0.754081946 c
15 -0.237346858 c
16 -0.051011439 c
17 -0.618675146 c
18 0.537612359 c
>From this data frame I want to create a "list" of length 3, where each
element of this list will be a vector corresponding to the value of y. For
example, 1st element will be all "x" values corresponding to the "y=a", and
similarly the other elements of this list. Can somebody point me how to do
this without having some "for" loop?
Thanks and regards,
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.