Learn R Programming

formatR (version 1.3)

tidy_dir: Format the R scripts under a directory

Description

This function first looks for all the R scripts under a directory (using the pattern "[.][RrSsQq]$"), then uses tidy_source to tidy these scripts. The original scripts will be overwritten with reformatted code if reformatting was successful. You may need to back up the original directory first if you do not fully understand the tricks tidy_source is using.

Usage

tidy_dir(path = ".", recursive = FALSE, ...)

Arguments

path
the directory
recursive
whether to recursively look for R scripts under path
...
other arguments to be passed to tidy_source

Value

  • Invisible NULL.

See Also

tidy_source

Examples

Run this code
library(formatR)

path = tempdir()
file.copy(system.file("demo", package = "base"), path, recursive = TRUE)
tidy_dir(path, recursive = TRUE)

Run the code above in your browser using DataLab