To create a dataset with repeated id numbers and corresponding values, and then group by the id and change values into separate columns in R, you can use the following code:
main.r529 chars22 lines
This will create a dataset with repeated id numbers and corresponding values, and then group by the id and change values into separate columns.
Example output:
main.r303 chars20 lines
Note that if there are different numbers of values for each id, the resulting columns will be filled with NA for the ids with fewer values.
If you want to avoid this and only keep the common number of values across all ids, you can use the following code instead:
main.r298 chars10 lines
gistlibby LogSnag