deparse在R 3.4.4和R 3.5中产生不同的结果.该新闻中心提出了一些默认设置已经改变了,但它不是我清楚如何保证deparse产生相同的输出中的R 3.4.4和R 3.5
R 3.4.4
> deparse(list(dec = 4L, b = "a"), control = "keepNA")
[1] "list(dec = 4, b = \"a\")"
Run Code Online (Sandbox Code Playgroud)
R 3.5
> deparse(list(dec = 4L, b = "a"), control = "keepNA")
[1] "list(4, \"a\")"
Run Code Online (Sandbox Code Playgroud)
编辑:
感谢@HongOoi和@akrun的有用建议,最接近解决方案的是确保R 3.4.4和R 3.5中的相同结果似乎是:
dctrl <- if (getRversion() > "3.4.4") c("keepNA", "niceNames") else "keepNA"
deparse(list(dec = 4L, b = "a"), control = dctrl)
Run Code Online (Sandbox Code Playgroud)
我们可以使用substituteinR 3.5来获得与 in 相同的结果R 3.4.4
deparse(substitute(list(dec = 4L, b = "a")), control = "keepNA")
#[1] "list(dec = 4, b = \"a\")"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
128 次 |
| 最近记录: |