Skip to contents

transpose a dataframe

Usage

tdf(x, colnames = NULL)

Arguments

x

dataframe

colnames

column names of the transposed dataframe

Value

dataframe

Examples


x <- c2r(mini_diamond, "id")
tdf(x)
#> # A tibble: 6 × 101
#>   item    `id-1` `id-2` `id-3` `id-4` `id-5` `id-6` `id-7` `id-8` `id-9` `id-10`
#>   <chr>   <chr>  <chr>  <chr>  <chr>  <chr>  <chr>  <chr>  <chr>  <chr>  <chr>  
#> 1 carat   "1.02" 1.51   "0.52" "1.54" "0.72" 2.02   "0.27" "0.51" "1.01" "0.70" 
#> 2 cut     "Fair" Good   "Idea… "Idea… "Idea… Fair   "Good" "Good" "Idea… "Fair" 
#> 3 clarity "SI1"  VS2    "VVS1" "SI2"  "VS1"  SI2    "VVS1" "SI2"  "SI1"  "VVS1" 
#> 4 price   " 302… 11746  " 202… " 945… " 249… 14080  "  75… " 102… " 559… " 1691"
#> 5 x       "6.25" 7.27   "5.15" "7.43" "5.73" 8.33   "4.10" "5.05" "6.43" "5.56" 
#> 6 y       "6.18" 7.18   "5.18" "7.45" "5.77" 8.37   "4.07" "5.08" "6.40" "5.41" 
#> # ℹ 90 more variables: `id-11` <chr>, `id-12` <chr>, `id-13` <chr>,
#> #   `id-14` <chr>, `id-15` <chr>, `id-16` <chr>, `id-17` <chr>, `id-18` <chr>,
#> #   `id-19` <chr>, `id-20` <chr>, `id-21` <chr>, `id-22` <chr>, `id-23` <chr>,
#> #   `id-24` <chr>, `id-25` <chr>, `id-26` <chr>, `id-27` <chr>, `id-28` <chr>,
#> #   `id-29` <chr>, `id-30` <chr>, `id-31` <chr>, `id-32` <chr>, `id-33` <chr>,
#> #   `id-34` <chr>, `id-35` <chr>, `id-36` <chr>, `id-37` <chr>, `id-38` <chr>,
#> #   `id-39` <chr>, `id-40` <chr>, `id-41` <chr>, `id-42` <chr>, …