Convert a list of lists to dataframe; requires that every list have same named elements.

util_list_to_df2(my_list, as_character = TRUE, on_empty = NA)

Arguments

my_list

A list of lists to dataframe

as_character

A logical value, indicating whether the values are read as character

on_empty

Value to return if my_list is NULL, NA or is length == 0, default = NA

Examples

util_list_to_df2(util_df_to_list(dplyr::starwars))
#> # A tibble: 87 × 14
#>    name     height mass  hair_color skin_color eye_color birth_year sex   gender
#>    <chr>    <chr>  <chr> <chr>      <chr>      <chr>     <chr>      <chr> <chr> 
#>  1 Luke Sk… 172    77    blond      fair       blue      19         male  mascu…
#>  2 C-3PO    167    75    NA         gold       yellow    112        none  mascu…
#>  3 R2-D2    96     32    NA         white, bl… red       33         none  mascu…
#>  4 Darth V… 202    136   none       white      yellow    41.9       male  mascu…
#>  5 Leia Or… 150    49    brown      light      brown     19         fema… femin…
#>  6 Owen La… 178    120   brown, gr… light      blue      52         male  mascu…
#>  7 Beru Wh… 165    75    brown      light      blue      47         fema… femin…
#>  8 R5-D4    97     32    NA         white, red red       NA         none  mascu…
#>  9 Biggs D… 183    84    black      light      brown     24         male  mascu…
#> 10 Obi-Wan… 182    77    auburn, w… fair       blue-gray 57         male  mascu…
#> # ℹ 77 more rows
#> # ℹ 5 more variables: homeworld <chr>, species <chr>, films <chr>,
#> #   vehicles <chr>, starships <chr>