R/fix_rscript.R

Defines functions fix_rscript

Documented in fix_rscript

fix_rscript <- function(file = NULL) {
  if(is.null(file)) file <- Sys.glob("*.R")
  if(length(file) != 1L) stop("exactly one .R file should be supplied")
  file.copy(file, "_orig.R")
  formatR::tidy_source(source = file, file = file,
    comment = TRUE, blank = TRUE, keep.space = FALSE, arrow = TRUE,
    indent = 2, width.cutoff = 80)
  x <- readLines(file)
  if(x[length(x)] == " FALSE") writeLines(x[-length(x)], file)
}

Try the jss package in your browser

Any scripts or data that you put into this service are public.

jss documentation built on July 12, 2024, 3:01 p.m.