How can I convert Json to data frame in R

后端 未结 2 986
广开言路
广开言路 2021-01-04 20:05

I\'d like to convert my json data to data frame in R. Here is what I\'ve done so far:

library(\"rjson\")
result <- fromJSON(file =\"mypath/data.json\")
js         


        
相关标签:
2条回答
  • 2021-01-04 20:37

    Try using jsonlite library. It work for me

    fromJSON(temp) %>% as.data.frame
    

    Following is output

    if you want list.

    fromJSON(temp) 
    
    0 讨论(0)
  • 2021-01-04 20:50

    Load the jsonlite package

    library(jsonlite)
    

    wine_json is a JSON

    wine_json <- '{"name":"Chateau Migraine", "year":1997, "alcohol_pct":12.4, "color":"red", "awarded":false}'
    

    Convert wine_json into a list:

    wine <- fromJSON(wine_json)
    

    Print structure of wine

    str(wine)
    
    0 讨论(0)
提交回复
热议问题