I have a dataframe with normal columns and list columns with list values.
I want to unnest the list column and then unnest the values of the lists in the same column.
Ok, my dataframe is result_2 and looks like this.
activity extrafields extrafields_2
<chr> <list> <list>
1 sale list list
2 sale list list
3 sale list list
4 sale list list
5 sale list list
6 sale list list
This is the first step
Unnest_1 <- result_2 %>%
unnest_wider(col = extrafields) %>%
unnest_wider(col = extrafields_2)
Gives me this:
activity details info
<chr> <list> <unknown>
1 sale list list
2 sale NULL list
3 sale NULL list
4 sale list list
5 sale list NULL
6 sale list NULL
The detail and info column contains a “label”, “type” and “value”.
What I want next is to have the values in the detail and info column like this:
activity details info
<chr> <chr> <chr>
1 sale telephone, internet, tv He was happy, pay less
2 sale NA tomorrow
3 sale NA nothing
4 sale Telephone tomorrow, nothing, he was happy
5 sale telephone, internet NA
6 sale tv NA
The detail and info column are just 2 of my examples, there are 20 more columns like this.
What can I do to get all the “values” in all the columns at once.