## Keep parse data in non interactive sessions.
if (!interactive())
op <- options(keep.source = TRUE)
## Correct use of spacing around '+' and '-' operators
fil <- tempfile(fileext = ".R")
cat("2 + 3",
"-2",
"(4\n + 2)",
"4 +\n2",
file = fil, sep = "\n")
ops_spaces_style(getSourceData(fil), c("'+'", "'-'"))
## Incorrect use of spacing around '>' and '!' operators
fil <- tempfile(fileext = ".R")
cat("2> 3",
"4 >2",
"6>3",
"! FALSE",
"!\nFALSE",
file = fil, sep = "\n")
ops_spaces_style(getSourceData(fil), c("GT", "'!'"))
Run the code above in your browser using DataLab