error in unnest_wider()

hi
i have a data frame that this df have a nested list and i want to unnset this all df . when
unnest_wider() function i get an error .
how to resolve this error or you have any idea for tidy this df?

df <- tibble(
a = list(c("a", "b"), "c"),
b = list(1:2,list(c("d", "f"))),
c = c(11, 22)
)

Error in col_to_wide():
! Can't combine ..1$...1 and ..3$...1 .

What is the desired final structure here ?

it's a json file that we want to tidy it

what would it look like when its tidy ?
how will you know that you got the 'correct' result ?

the list's seperate in column's.

how many columns should there be in the result for your example ? can you say the number ?

the number of return column's is based on the list that we have. for example in b column we have two list that return two columns.

So the first row should have 5 columns, and the bottom row should have 4 columns ? Does alignment matter because data.frames have to be rectangular and 5 and 4 columns would not be...

Do the names of the columns matter or no?

df %>%
mutate(b = map(b, as.character)) %>%
unnest_wider(b)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.