I have a dataframe with nested lists in the columns. Since it has been read in from a csv, the columns are formatted as characters.
Dummy data for reproduction:
col1 <- c("list1",
"list2",
"emptylist",
"list3")
col2 <-c("[{'test': 1, 'test2': 2, 'test3': 'string'}, {'test': 1, 'test2': 2, 'test3': 'string2'}]",
"[{'test3': 5, 'test4': 6, 'test5': 'string3'}, {'test': 7, 'test6': 8, 'test7': 'string4'}]",
"",
"[{'test9': 9, 'test10': 10, 'test11': 'string11'}, {'test12': 12, 'test13': 13, 'test14': 'string14'}]")
mydf <- data.frame(col1, col2)
In order to use something like mydf %>% dplyr::unnest(col2), I first need to format the column from character to list. Is this possible, if not, what alternative solution might be used?