用R解析JSON [英] Parse JSON with R

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

问题描述

我对R相当陌生,但是使用它的次数越多,我看到的就比SAS或SPSS真正强大得多.正如我所看到的,其中的主要好处之一就是能够从Web上获取和分析数据.我想这是可能的(甚至可能很简单),但是我正在寻找解析Web上公开可用的JSON数据的方法.我决不是一名程序员,因此,您能提供的任何帮助和说明将不胜感激.即使您为我提供了一个基本的工作示例,我也可能会完成它.

I am fairly new to R, but the more use it, the more I see how powerful it really is over SAS or SPSS. Just one of the major benefits, as I see them, is the ability to get and analyze data from the web. I imagine this is possible (and maybe even straightforward), but I am looking to parse JSON data that is publicly available on the web. I am not a programmer by any stretch, so any help and instruction you can provide will be greatly appreciated. Even if you point me to a basic working example, I probably can work through it.

推荐答案

RJSONIO 是另一种方法软件包,提供用于读取和写入JSON格式的数据的工具.

RJSONIO from Omegahat is another package which provides facilities for reading and writing data in JSON format.

rjson 不使用S4/S3方法,因此不容易扩展,但仍然有用.不幸的是,它没有使用向量化操作,因此对于非平凡的数据来说太慢了.同样,对于将JSON数据读入R来说,它有些慢,因此不能扩展到大数据,如果这是一个问题的话.

rjson does not use S4/S3 methods and so is not readily extensible, but still useful. Unfortunately, it does not used vectorized operations and so is too slow for non-trivial data. Similarly, for reading JSON data into R, it is somewhat slow and so does not scale to large data, should this be an issue.

更新(新软件包2013-12-03):

Update (new Package 2013-12-03):

jsonlite :此软件包是RJSONIO包.它基于RJSONIO的解析器构建,但在R对象和JSON字符串之间实现了不同的映射.此程序包中的C代码大部分来自RJSONIO程序包,R代码已从头开始重写.除了fromJSONtoJSON的直接替代品之外,该软件包还具有序列化对象的功能.此外,该软件包还包含许多单元测试,以确保所有边缘情况均得到一致的编码和解码,以与系统和应用程序中的动态数据一起使用.

jsonlite: This package is a fork of the RJSONIO package. It builds on the parser from RJSONIO but implements a different mapping between R objects and JSON strings. The C code in this package is mostly from the RJSONIO Package, the R code has been rewritten from scratch. In addition to drop-in replacements for fromJSON and toJSON, the package has functions to serialize objects. Furthermore, the package contains a lot of unit tests to make sure that all edge cases are encoded and decoded consistently for use with dynamic data in systems and applications.

这篇关于用R解析JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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