fromjson与不同的行

时间:2017-06-12 21:04:14

标签: json r multirow

我试图一次性转换带有R的json文件。不幸的是,这种方法给我一个错误,如下所述:

> fromJSON(res.clean[,2])
Error: parse error: trailing garbage
          :{"b64_value":"AAAAAA=="}}}] [{"loc":[{"N":9.03553},{"N":45.
                     (right here) ------^

如果相反我一行一行,一切都很好

> fromJSON(res.clean[1,2])
                 loc  recorded_at fields.b64_value fields.b64_value fields.b64_value
1  9.03913, 45.61335 1.476451e+12         AAAC1g==             <NA>             <NA>
2  9.03924, 45.61362 1.476451e+12         AAAM+Q==             <NA>             <NA>
3  9.03995, 45.61365 1.476451e+12         AAAL2A==             <NA>             <NA>
4  9.04005, 45.61340 1.476451e+12             <NA>             <NA>             <NA>
5  9.04017, 45.61406 1.476451e+12         AAAUGg==             <NA>             <NA>
6  9.03949, 45.61419 1.476451e+12         AABLBw==             <NA>             <NA>
7  9.03496, 45.61319 1.476451e+12             <NA>         AAAABA==             <NA>
8  9.03440, 45.61295 1.476451e+12         AAArMQ==             <NA>             <NA>
9  9.03448, 45.61285 1.476451e+12             <NA>             <NA>             <NA>
10 9.03495, 45.61241 1.476451e+12         AAAAAA==             <NA>             AA==
> fromJSON(res.clean[2,2])
                 loc  recorded_at fields.b64_value fields.b64_value fields.b64_value
1  9.03553, 45.61197 1.476451e+12         AABUkQ==         AAAAAg==             <NA>
2  9.03559, 45.61188 1.476451e+12             <NA>             <NA>             <NA>
3  9.03606, 45.61129 1.476451e+12         AAAcSQ==             <NA>             <NA>
4  9.03712, 45.61127 1.476451e+12             <NA>             <NA>             <NA>
5  9.04059, 45.61095 1.476451e+12             <NA>             <NA>             <NA>
6  9.04115, 45.61091 1.476451e+12             <NA>             <NA>             <NA>
7  9.04440, 45.61064 1.476451e+12             <NA>             <NA>             <NA>
8  9.04444, 45.61067 1.476451e+12         AAAmaQ==             <NA>             <NA>
9  9.04456, 45.61115 1.476451e+12         AABq3g==             <NA>             <NA>
10 9.04445, 45.61179 1.476451e+12         AABKuQ==             <NA>             <NA>
11 9.04303, 45.61281 1.476451e+12         AABY6Q==             <NA>             <NA>
12 9.04010, 45.61327 1.476451e+12             <NA>             <NA>             <NA>
13 9.04009, 45.61331 1.476451e+12         AAAmBA==             <NA>             <NA>
14 9.03989, 45.61365 1.476452e+12             <NA>             <NA>             AA==
15 9.03989, 45.61365 1.476452e+12         AAAAAA==             <NA>             <NA>

有没有办法做同样的事情我一个接一个地做?我想避免运行for循环

for (i in 1:max){
fromJSON(res.clean[i,2])}

非常感谢你的帮助

0 个答案:

没有答案