我在r中有如下数据框
> `drop-out-rate.csv`[1:6 , 1:2]
State_UT year Primary_Boys
1 A & N Islands 2012-13 0.83
2 A & N Islands 2013-14 1.35
3 A & N Islands 2014-15 0.47
4 Andhra Pradesh 2012-13 3.3
5 Andhra Pradesh 2013-14 4.31
6 Andhra Pradesh 2014-15 6.57
我希望将其转换为以下形式:
> `drop-out-rate_tmp.csv`[1:2 , 1:4]
State_UT Primary_Boys_12-13 Primary_Boys_13-14 Primary_Boys_14-15
1 A & N Islands 0.83 1.35 0.47
2 Andhra Pradesh 3.3 4.31 6.57
是否有直接方法可以这样做,否则我将不得不手动编码?