'How to write a dataFrame with nestest dataframe to csv in R

I've got a dataFrame via spotify api which contains the data of a playlist. I want to write the song title and the artist to a csv. problem is the dataframe contains a column track.artists which is a dataFrame itself with just one row, which contains a column whith the artist name.

so this doesnt work:

playlist %>%
   select(track.name, track.artist) %>%
   write.csv(path, row.names=FALSE)

I get the error "Unimplemented type 'list' in EncoderElement"



Solution 1:[1]

Does this work for you?

playlist %>%
  select(track.name, track.artist) %>%
  unnest(track.artist) %>% 
  write.csv(path, row.names=FALSE)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 langtang