I have a dataframe that looks as follows:
| Rest of data frame | columnToSeparate |
|---|---|
| blablarow1 | {"info1":"row1string1","info2":"row1string2"} |
| blablarow2 | {"info1":"row2string1","info2":"row2string2"} |
What is the best way to extract this information as separate columns in my dataframe to get something like:
| Rest of data frame | info1 | info2 |
|---|---|---|
| blablarow1 | row1string1 | row1string2 |
| blablarow2 | row2string1 | row2string2 |
Here is code to create the dataframe
df <- data.frame(RestOfDF = c("blablarow1", "blablarow2"),
columnToSeparate = c('{"info1":"row1string1","info2":"row1string2"}',
'{"info1":"row2string1","info2":"row2string2"}'))
Update: My real column has lots of infoN fiels, so I am looking to do something as automatic as possible as the names are actually different. Something like {"mydogsname":"pinky","mycatsfood":"icecream"...}