Try with add_rownames
add_rownames(mtcars) %>%
gather(var, value, -rowname) %>%
spread(rowname, value)
In the newer version, rownames_to_column
replaces add_rownames
mtcars %>%
rownames_to_column %>%
gather(var, value, -rowname) %>%
spread(rowname, value)
In the even newer version, pivot_wider
replaces spread
:
mtcars %>%
tibble::rownames_to_column() %>%
pivot_longer(-rowname) %>%
pivot_wider(names_from=rowname, values_from=value)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…