Hello there!
I cant believe I am struggling with this simple question. Here is my list.
list('col1' = 2, 'col2' = NULL, col3 = 'wow')
$col1
[1] 2
$col2
NULL
$col3
[1] "wow"
I am trying to convert it to a one-row tibble where the columns are col1, col2 and col3.
Because of the NULL, as_tibble() does not work. And enframe() does not use the column names (they are stored as variables...). I am lost here.
> list('col1' = 2, 'col2' = NULL, col3 = 'wow') %>% as_tibble(validate = FALSE)
Error: All columns in a tibble must be 1d or 2d objects:
* Column `col2` is NULL
Call `rlang::last_error()` to see a backtrace
> list('col1' = 2, 'col2' = NULL, col3 = 'wow') %>% enframe()
# A tibble: 3 x 2
name value
<chr> <list>
1 col1 <dbl [1]>
2 col2 <NULL>
3 col3 <chr [1]>
Any ideas?
Thanks!