If you want to transpose a dataframe according to a specific column in R, you can use the tidyr package's gather and spread functions.
Here's an example code snippet that demonstrates how to do this:
main.r329 chars17 lines
In this example, the gather function is used to pivot the dataframe from wide to long format, with the variable column being used as the column to pivot on. Then, spread is used to pivot the dataframe back to wide format, with variable becoming the column names.
gistlibby LogSnag