将数据从JSON文件导入R [英] Importing data from a JSON file into R

查看:112
本文介绍了将数据从JSON文件导入R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有将JSON文件中的数据导入R的方法?更具体地说,该文件是带有字符串字段,对象和数组的JSON对象的数组.关于如何处理此 http:/,RJSON软件包尚不清楚/cran.r-project.org/web/packages/rjson/rjson.pdf .

Is there a way to import data from a JSON file into R? More specifically, the file is an array of JSON objects with string fields, objects, and arrays. The RJSON Package isn't very clear on how to deal with this http://cran.r-project.org/web/packages/rjson/rjson.pdf.

推荐答案

首先安装 rjson 软件包:

First install the rjson package:

install.packages("rjson")

然后:

library("rjson")
json_file <- "http://api.worldbank.org/country?per_page=10&region=OED&lendingtype=LNX&format=json"
json_data <- fromJSON(paste(readLines(json_file), collapse=""))

更新:自0.2.1版起

json_data <- fromJSON(file=json_file)

这篇关于将数据从JSON文件导入R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆