大家好!我有用于解析 JSON 文件的简单 R 脚本:
json <-
rjson::fromJSON(readLines('http://data.rada.gov.ua/ogd/zpr/skl8/bills-
skl8.json', warn=F))
bills <- data.frame(
id = numeric(),
title = character(),
type = character(),
subject = character(),
rubric = character(),
executive = character(),
sesion = character(),
result = character()
)
for (row in json)
{
bill <- data.frame(
id = row$id,
title = row$title,
type = row$type,
subject = row$subject,
rubric = row$rubric,
executive = row$mainExecutives$executive$department,
sesion = row$registrationSession,
result = row$currentPhase$title
)
bills <- rbind(bills, bill)
}
但是我在 data.frame(id = row$id, title = row$title, type = row$type, subject = row$subject, 中有错误:参数暗示不同的行数:1, 0
所以,我的 JSON 文件在 277 行有 NULL 值。我可以跳过此错误或替换循环中的 NULL 值吗?谢谢!