Created
May 3, 2016 13:56
-
-
Save danielecook/9bd19cbda9f566a224b7291f2b58bae9 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