convert column values to row in r code example
Example 1: convert a row to a column in r
library(tidyverse)
starting_df %>%
rownames_to_column() %>%
gather(variable, value, -rowname) %>%
spread(rowname, value)
Example 2: convert a row to a column in r
starting_df <- data.frame(row.names= c(LETTERS[1:4]),
a = c(1:4),
b = seq(0.02,0.08,by=0.02),
c = c("Aaaa","Bbbb","Cccc","Dddd")
)