- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
更新:
tl; dr是RJSONIO
不再是两个选项中最快的一个。相反,rjson
现在更快了。
查看评论以进一步确认结果
我的印象是RJSONIO
应该比rjson
更快。
但是,我得到相反的结果。
我的问题是:
是否可以/应该进行任何调整以改善RJSONIO
的结果?
(即,我在俯视什么吗?)
以下是使用实际数据(其中U
是json网页的内容)然后是模拟的json的比较
## REAL DATA
library(microbenchmark)
> microbenchmark(RJSONIO::fromJSON(U), rjson::fromJSON(U))
Unit: milliseconds
expr min lq median uq max
1 rjson::fromJSON(U) 29.46913 30.16218 31.74999 34.11012 158.6932
2 RJSONIO::fromJSON(U) 175.11514 181.67742 186.52871 195.90646 414.6160
> microbenchmark(RJSONIO::fromJSON(U, simplify=FALSE), rjson::fromJSON(U))
Unit: milliseconds
expr min lq median uq max
1 rjson::fromJSON(U) 27.92341 28.7430 29.60091 30.63291 1 143.9478
2 RJSONIO::fromJSON(U, simplify = FALSE) 173.30136 179.5815 183.94315 190.17245 2 328.8996
# MOCK DATA
U <- toJSON(list(1:10, LETTERS, letters, rnorm(20)))
microbenchmark(RJSONIO::fromJSON(U), rjson::fromJSON(U))
# Unit: microseconds
# expr min lq median uq max
# 1 rjson::fromJSON(U) 94.788 100.8650 105.6035 111.0740 3457.479
# 2 RJSONIO::fromJSON(U) 520.131 527.7775 533.2715 555.2415 942.136
iris
数据集
Iris.JSON <- toJSON(iris)
microbenchmark(RJSONIO::fromJSON(Iris.JSON), rjson::fromJSON(Iris.JSON))
# Unit: microseconds
# expr min lq median uq max
# 1 rjson::fromJSON(Iris.JSON) 229.669 235.571 238.511 241.423 260.164
# 2 RJSONIO::fromJSON(Iris.JSON) 1209.607 1224.793 1232.165 1238.953 12039.772
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.8.8 stringr_0.6.1 RJSONIO_1.0-1 rjson_0.2.11
loaded via a namespace (and not attached):
[1] plyr_1.7.1
最佳答案
> library('BBmisc')
> suppressAll(lib(c('RJSONIO','rjson','jsonlite','microbenchmark')))
> U <- toJSON(list(1:10, LETTERS, letters, rnorm(20)))
> microbenchmark(
+ rjson::toJSON(U),
+ RJSONIO::toJSON(U),
+ jsonlite::toJSON(U, dataframe = "column"),
+ times = 10
+ )
Unit: microseconds
expr min lq mean median uq max neval cld
rjson::toJSON(U) 65.174 68.767 2002.7007 88.2675 103.151 19179.224 10 a
RJSONIO::toJSON(U) 299.186 304.832 482.8038 329.7210 493.683 1351.727 10 a
jsonlite::toJSON(U, dataframe = "column") 485.985 501.381 555.4192 548.5935 587.083 708.708 10 a
> microbenchmark(
+ system.time(rjson::toJSON(U)),
+ system.time(RJSONIO::toJSON(U)),
+ system.time(jsonlite::toJSON(U, dataframe = "column")),
+ times = 10)
Unit: milliseconds
expr min lq mean median uq max neval cld
system.time(rjson::toJSON(U)) 112.0660 115.8677 119.8426 119.8372 121.6908 132.2111 10 ab
system.time(RJSONIO::toJSON(U)) 115.4223 118.0262 129.2758 120.5690 148.5175 151.6874 10 b
system.time(jsonlite::toJSON(U, dataframe = "column")) 113.2674 114.9096 118.0905 117.8401 120.9626 123.6784 10 a
关于r - RJSONIO vs rjson-更好的调优,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15308435/
我的 rjson 包随机不起作用。例如,它有时工作正常,有时无法加载。不知道为什么。 我收到此错误。 Error in library("rjson") : there is no pack
我有一个包含多个列的 sqlite 数据库文件。其中一列中嵌入了一个 JSON 字典(带有两个键)。我想将 JSON 列提取到 R 中的数据框中,在单独的列中显示每个键。 我试过 rjson::fro
rjson::fromJSON() 读取文件不正确,而 jsonlite::fromJSON() 读取正常。这是一个示例示例。 文件 test.json 内容: {"name": "Sanjay",
更新: tl; dr是RJSONIO不再是两个选项中最快的一个。相反,rjson现在更快了。 查看评论以进一步确认结果 我的印象是RJSONIO应该比rjson更快。 但是,我得到相反的结果。 我的问
我正在尝试处理一些 JSON 格式的数据。 rjson::fromJSON 成功导入数据并将其放入一个非常笨重的列表中。 library(rjson) y data.frame(year, do.c
我花了很长时间使用 R 来尝试抓取 NBA 数据,到目前为止我都是通过反复试验来完成的,但最后我发现了这个 documentation 。前段时间我在抓取 shotchartdetail 时遇到了一些
让我们: desired_output="{a:'1', b:'foo'}" D = list(a=1, b="foo") 然后: out = toJSON(D) out "{\"a\":1,\"b\
给出以下 R 代码: library(rjson) x <- c(3:5) toJSON(x) 它产生: [1] "[3,4,5]" 当我期待类似的事情时: "[3,4,5]" 我是 R 新手,我想这
我当然可以在 R 中解决这个下游的问题,但我认为与让 rjson 以某种方式为我做这件事相比,这会更加困惑。可以做到吗? 最佳答案 两个想法: 看看RJSONIO相反,并使用它的 fromJSON .
我是一名优秀的程序员,十分优秀!