[R] split data frame by factor

ivan i.petzev at gmail.com
Mon Apr 25 23:28:00 CEST 2011


Dear Community,

I have a dataframe like this one:

A	B
5	1
6	1
7	1
8	1
9	2
10	2
11	2
12	2

I have a problem splitting up the above data frame in respect to the
factor represented by B, whereas the resulting vector should contain
the numeric values only. I tried split() but it produces this:
A	B
[1]
5	1
6	1
7	1
8	1
[2]
9	2
10	2
11	2
12	2

I want to achieve this,though:

A	
[1]
5	
6	
7	
8
[2]	
9	
10	
11	
12	

How is this done? Thank you very much in advance.

Best Regards.



More information about the R-help mailing list