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

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

问题描述

我对 R 相当陌生,但使用它越多,我就越能看到它在 SAS 或 SPSS 上的真正强大之处.在我看来,主要好处之一是能够从网络获取和分析数据.我想这是可能的(甚至可能很简单),但我希望解析网络上公开可用的 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 方法并且so 不容易扩展,但仍然有用.不幸的是,它没有使用矢量化操作,因此对于非平凡数据来说太慢了.同样,将 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天全站免登陆