I'm seeing some strange behavior trying to use tidyr::unnest()
on a data frame that was created from jsonlite::stream_in()
. I read in the data from a JSON file and in the file the labels
field is an array of string values, so I understand that it is being parsed in as an atomic vector. I'm getting the following message when I try to unnest:
Error: Each column must either be a list of vectors or a list of data frames [labels]
As far as I can see the labels
column is a list of character vectors:
> transactions
# A tibble: 37,057 x 6
rowkey price quantity animalRowKey labels transactionDay
* <chr> <dbl> <dbl> <chr> <list> <chr>
1 13652:1:SMIWY:112301:4:0 15.2 1.00 13652:1:SMIWY7 <chr [1]> 2010-08-05
2 13652:1:SMIWY:112369:3:0 18.0 1.00 13652:1:SMIWY7 <chr [1]> 2010-08-07
3 13652:1:SMIWY:113107:7:0 89.4 1.00 13652:1:SMIWY7 <chr [1]> 2010-08-31
4 13652:1:SMIWY:115041:2:0 28.8 1.00 13652:1:SMIWY7 <chr [2]> 2010-11-01
5 13652:1:SMIWY:119353:4:0 7.00 1.00 13652:1:SMIWY7 <chr [1]> 2011-04-05
but when I get this:
> transactions_cleaned <- transactions %>% unnest()
Error: Each column must either be a list of vectors or a list of data frames [labels]
if it's not a list of vectors, how can I figure out what type of object is in that column?