简体   繁体   English

将嵌套的 json 文件读入 R 并写入 csv

[英]Read nested json file into R and write to csv

How can I read in this json file from the COVID Act Now API, convert to data frame, and write to CSV?如何从 COVID Act Now API 读取json 文件,转换为数据帧,然后写入 CSV?

It seems to be in some special nested json format and I am getting this error in R它似乎是一些特殊的嵌套 json 格式,我在 R 中收到此错误

AL <- as.data.frame(fromJSON(file = "https://data.covidactnow.org/latest/us/states/AL.OBSERVED_INTERVENTION.timeseries.json"))

Error in fromJSON(file = "https://data.covidactnow.org/latest/us/states/AL.OBSERVED_INTERVENTION.timeseries.json"): argument "txt" is missing, with no default fromJSON(file = "https://data.covidactnow.org/latest/us/states/AL.OBSERVED_INTERVENTION.timeseries.json") 中的错误:缺少参数“txt”,没有默认值

Try this:尝试这个:

library(jsonlite)

AL <- as.data.frame(fromJSON(txt = "https://data.covidactnow.org/latest/us/states/AL.OBSERVED_INTERVENTION.timeseries.json"))

Notice the name of the argument: txt , not file .注意参数的名称: txt ,而不是file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM