I am trying to parse json data that sits in one of the columns of my dataframe.
I want to unlist data from that column and make specific column for each key in that json data enter image description here
I am trying to parse json data that sits in one of the columns of my dataframe.
I want to unlist data from that column and make specific column for each key in that json data enter image description here
Since I can't read your data properly, I am assuming your table name is: Table and Column name is: methodology.
Methodology
{"first_value":332.76,"last_value":335.05}
{"first_value":573.5,"last_value":573.5}
{"first_value":42.63,"last_value":42.63}
{"first_value":0.44,"last_value":0.44}
{"first_value":0.0,"last_value":0.0}
{"first_value":92.0,"last_value":92.0}
library(jsonlite)
json <- lapply( paste0("[", Table$Methodology, "]" ),
function(x) jsonlite::fromJSON(x)
)
##json is a list which you have to unlist and form a dataframe
##you have to set the nrow for your convenience
d <- data.frame(matrix(unlist(json), nrow=100, byrow=T))
The output is somewhat like:
head(df)
X1 X2
1 332.76 335.05
2 573.50 573.50
3 42.63 42.63
4 0.44 0.44
5 0.00 0.00
6 92.00 92.00