I have a dataframe (all elements numerics) that looks like this:
var1 var2 var3
1 1 10
1 3 30
1 2 20
2 6 30
2 4 20
2 2 10
I'd like to rearrange in this way (var1 should be rownames without repetition and var2 should be the first row):
1 2 3 4 6
1 10 20 30 NA NA
2 NA 10 NA 20 30
Note that colunm 5 is skipped because var2 doesnt have '5' value. I have problems to choose a kind method to handle with this.
Which R function/package do you recommend me? Is it easier to get that with Linux commands?