How do I flip rows and columns in R
Assuming you have this data frame df, see data below. First you have to transpose all data frame except the first column. The result being a matrix that we need to convert to a data frame. Finally, we assign as column names of df2the first column of the original data frame df. Output: Data: