我想以符合整洁评估的方式整理源代码。不幸的是,formatR
不保存!!
运算符。
formatR::tidy_source(text = "!!little_b", output = FALSE)$text.tidy
## [1] "!(!little_b)"
来自Yihui 的 formatR 指南的第 7 节,
简而言之,tidy_source(text = code) 基本上是 deparse(parse(text = code))...
但是当我打电话时deparse(parse(text = code))
,文本无法使用。实际行为:
deparse(parse(text = "1+!!x"))
## [1] "structure(expression(1 + (!(!x))), srcfile = <environment>, wholeSrcref = structure(c(1L, "
## [2] "0L, 2L, 0L, 0L, 0L, 1L, 2L), srcfile = <environment>, class = \"srcref\"))"
期望的结果是整齐的文本:
"1 + !!x
这里的解决方案可能会解决https://github.com/ropensci/drake/issues/200。