How to reshuffle my data.frame in specific order in R

时间:2017-12-18 05:27:24

标签: r dataframe

I have data.frame in R which have a form like following:

ID Label1 Label2(code)   total_number(it's a number)  
1  AAA    2211123        100000
1  AAA    2222313        120304
2  AAB    2234123        234145
2  AAB    3123412        1000
4  ADD    1231566        200
4  AAB    3155032        30000
.
.
.

What I want to do is to make each Label2 as a feature however, when I make them as a feature I'd like to sort all Label2 who shares same Label1 together lexicographically.

Label1 has 162 different elments and Label2 has 1200around different elements.

So the final result would be look like :

ID 2211123(AAA) 222313(AAA) 2234123(AAB) 3155032(AAB) 3155032(AAB)
1   10000       120304           0           0          
2    0            0            1000
3   
4                                                        300000

How can I do this?

0 个答案:

没有答案