I have read several questions similar to mine but none actually answered my dilemma (so to speak). I have a dataset composed of 2 columns: on the first column there are x numbers of usernames repeated 100 times each (i.e. if there are 4 usernames these generates 400 rows under a column named "user") and under column 2 there are non-unique strings corresponding to each username. I want to transpose the UNIQUE usernames from rows to columns but maintaining all the values in col2 without aggregation. For simplicity I add below a small sample from iris dataset. In essence I would like to reshape this:
Species Petal.Width
setosa 0.2
setosa 0.2
setosa 0.4
versicolor 1.4
versicolor 1.3
versicolor 1.0
To this:
setosa versicolor
0.2 1.4
0.2 1.3
0.4 1.0
without having to manually subsetting the data, as there will be several usernames and the code may be tediously long to complete. It is actually a replacement of columns (from Species to setosa and versicolor in the example above). Could someone please let me know if there is a quick way to achieve this result? Thanks!