> data.long
fy company revenue profit
1 2010 Apple 65225 14013
2 2011 Apple 108249 25922
3 2012 Apple 156508 41733
4 2010 Google 29321 8505
5 2011 Google 37905 9737
6 2012 Google 50175 10737
7 2010 Microsoft 62484 18760
8 2011 Microsoft 69943 23150
9 2012 Microsoft 73723 16978
> data.wide <-reshape(data.long,
+ idvar = "company",
+ timevar = "fy",
+ times = c(seq(from = 2010, to = 2012, by = 1)),
+ v.names = c("revenue", "profit"),
+ direction = "wide")
> data.wide
company revenue.2010 profit.2010 revenue.2011 profit.2011 revenue.2012 profit.2012
1 Apple 65225 14013 108249 25922 156508 41733
4 Google 29321 8505 37905 9737 50175 10737
7 Microsoft 62484 18760 69943 23150 73723 16978
>


雷达卡


京公网安备 11010802022788号







