-
-
Save javieroot/c53e5dd0bb6ebe13f08d2f3dde452870 to your computer and use it in GitHub Desktop.
Transpose data frame R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tFrame <- function(x) { | |
x <- t(x) | |
row_names <- row.names(x)[2:length(row.names(x))] | |
col_names <- x[1,] | |
x <- tbl_df(as.data.frame(x[2:nrow(x),])) | |
colnames(x) <- col_names | |
rownames(x) <- row_names | |
x <- dplyr::add_rownames(x, var = "strain") | |
x | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment