[Experimental]

Is an alternative to t() to transpose a data frame. The first column of df will become column names in the transposed data.

transpose_df(df)

Arguments

df

A data frame to be transposed.

Value

A tibble containing the transposed data.

Examples

# \donttest{ library(metan) df <- data.frame( GEN = c("G1", "G2", "G3","G4"), E1 = rnorm(4, 100, 20), E2 = rnorm(4, 10, 2), E3 = rnorm(4, 50, 5), E4 = rnorm(4, 1000, 150) ) df
#> GEN E1 E2 E3 E4 #> 1 G1 104.89280 10.332382 59.79362 919.8328 #> 2 G2 75.89245 12.794000 50.08101 987.3939 #> 3 G3 70.81251 7.959122 37.88328 1025.3137 #> 4 G4 107.48292 10.577962 42.55318 970.1600
t(df)
#> [,1] [,2] [,3] [,4] #> GEN "G1" "G2" "G3" "G4" #> E1 "104.89280" " 75.89245" " 70.81251" "107.48292" #> E2 "10.332382" "12.794000" " 7.959122" "10.577962" #> E3 "59.79362" "50.08101" "37.88328" "42.55318" #> E4 " 919.8328" " 987.3939" "1025.3137" " 970.1600"
transpose_df(df)
#> # A tibble: 4 x 5 #> name G1 G2 G3 G4 #> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 E1 105. 75.9 70.8 107. #> 2 E2 10.3 12.8 7.96 10.6 #> 3 E3 59.8 50.1 37.9 42.6 #> 4 E4 920. 987. 1025. 970.
# }