Skip to contents

trans list into data.frame

Usage

list2df(x, rownames = TRUE, colnames = NULL, method = "row")

Arguments

x

list

rownames

use rownames or not

colnames

colnames of the output

method

one of row, col, set each item as row or col, default as row

Value

tibble

Examples

x <- list(
  c("a", "1"),
  c("b", "2"),
  c("c", "3")
)

list2df(x, colnames = c("char", "num"))
#>     char num
#> It1    a   1
#> It2    b   2
#> It3    c   3

x <- list(
  c("a", "b", "c"),
  c("1", "2", "3")
)

list2df(x, method = "col")
#>   It1 It2
#> 1   a   1
#> 2   b   2
#> 3   c   3