I want to tidy up source code in a way that is compliant with tidy evaluation. Unfortunately, formatR
does not preserve the !!
operator.
formatR::tidy_source(text = "!!little_b", output = FALSE)$text.tidy
## [1] "!(!little_b)"
From Section 7 of Yihui's formatR guide,
In a nutshell, tidy_source(text = code) is basically deparse(parse(text = code))...
But when I call deparse(parse(text = code))
, the text is unusable. Actual behavior:
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\"))"
The desired result is tidied text:
"1 + !!x
A solution here would probably solve https://github.com/ropensci/drake/issues/200.