formatR.R 317 bytes
# use formatR package to tidy code
library(formatR)
for (f in dir(".", pattern = "*.R")) {
    cat("Cleaning ", f, "\n")
    tidy.source(f, file = f)
for (f in c(dir(".", pattern = "*.R"), dir("R", pattern = "*.R", full.names = TRUE))) {
    cat("Cleaning ", f, "\n")
    tidy.source(f, file = f)