0

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 enter image description here

phiver
  • 23,048
  • 14
  • 44
  • 56
  • Please insert a bit of your data with dput(head(my_data.frame)) instead of a picture of your data. We can't use a picture. Also what have you tried already. Please read [how to create a reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – phiver May 14 '18 at 12:50

1 Answers1

0

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
Farah Nazifa
  • 909
  • 8
  • 14