我过去几天一直在尝试将我的JSON文件导入R中,并且我尝试了几种方法,但到目前为止还没有运气。
文件的部分内容如下:
[{"xmin":51.90606732,"xmax":51.906426887100714,"ymin":4.46843454,"ymax":4.469002225180884,"measures":[],"sum":0,"mean":null,"variance":-0.0,"stdev":0.0,"count":0,"maxdb":null,"mindb":null},
{"xmin":51.90606732,"xmax":51.906426887100714,"ymin":4.469002225180884,"ymax":4.469569910361769,"measures":[],"sum":0,"mean":null,"variance":-0.0,"stdev":0.0,"count":0,"maxdb":null,"mindb":null},
{"xmin":51.90606732,"xmax":51.906426887100714,"ymin":4.469569910361769,"ymax":4.470137595542654,"measures":[],"sum":0,"mean":null,"variance":-0.0,"stdev":0.0,"count":0,"maxdb":null,"mindb":null},
{"xmin":51.90606732,"xmax":51.906426887100714,"ymin":4.470137595542654,"ymax":4.470705280723538,"measures":[],"sum":0,"mean":null,"variance":-0.0,"stdev":0.0,"count":0,"maxdb":null,"mindb":null}]
我想问一下是否有人能够指出最适合将此.json文件导入R的技术,以及有关如何清理数据以进行分析的一些想法(即描述性统计和可视化) )
非常感谢, 雨果
答案 0 :(得分:-1)
使用jsonlite包:
>library(jsonlite)
>a = '[{"xmin":51.90606732,"xmax":51.906426887100714,"ymin":4.46843454,"ymax":4.469002225180884,"measures":[],"sum":0,"mean":null,"variance":-0.0,"stdev":0.0,"count":0,"maxdb":null,"mindb":null},
{"xmin":51.90606732,"xmax":51.906426887100714,"ymin":4.469002225180884,"ymax":4.469569910361769,"measures":[],"sum":0,"mean":null,"variance":-0.0,"stdev":0.0,"count":0,"maxdb":null,"mindb":null},
{"xmin":51.90606732,"xmax":51.906426887100714,"ymin":4.469569910361769,"ymax":4.470137595542654,"measures":[],"sum":0,"mean":null,"variance":-0.0,"stdev":0.0,"count":0,"maxdb":null,"mindb":null},
{"xmin":51.90606732,"xmax":51.906426887100714,"ymin":4.470137595542654,"ymax":4.470705280723538,"measures":[],"sum":0,"mean":null,"variance":-0.0,"stdev":0.0,"count":0,"maxdb":null,"mindb":null}]'
> b = fromJSON(a)
> b
xmin xmax ymin ymax measures sum mean variance stdev count
1 51.90607 51.90643 4.468435 4.469002 NULL 0 NA 0 0 0
2 51.90607 51.90643 4.469002 4.469570 NULL 0 NA 0 0 0
3 51.90607 51.90643 4.469570 4.470138 NULL 0 NA 0 0 0
4 51.90607 51.90643 4.470138 4.470705 NULL 0 NA 0 0 0
maxdb mindb
1 NA NA
2 NA NA
3 NA NA
4 NA NA