Edit: This is a similar question to this one but I'm explicitly after a tidyr/dplyr approach.
I'm curious if there's a neat "tidyr/dplyr" way of doing this kind of transposing?
I've got different (by ID) observations (v2,v2,v3) of the same phenomenon (key) currently in "long" format, and for presentation, I'd like a wide format with one phenomenon (key) per row, but each set of observations (ID,v1,v2,v3) in repeated sets of columns with appropriately incremented variable names
In this case, I know that there are only going to be 2 IDs so I split it into two frames of tables and joined them.
I'd like any pointers on a general tidyr way of turning:
key ID v1 v2 v3
32 blue 8.550 0.782 78.281
32 green 9.200 1.680 95.354
22 orange 6.100 -0.143 44.320
22 pink 6.500 0.672 74.920
100 green 4.500 -0.460 32.280
100 blue 8.000 0.506 69.372
Into:
key IDa v1 v2 v3 IDb v1b v2b v3b
32 blue 8.550 0.782 78.281 green 9.200 1.680 95.354
22 orange 6.100 -0.143 44.320 pink 6.500 0.672 74.920
100 green 4.500 -0.460 32.280 blue 8.000 0.506 69.372
Thanks!