library(tidyverse) starting_df %>% rownames_to_column() %>% gather(variable, value, -rowname) %>% spread(rowname, value)