Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tidy_dir

Format all R scripts under a directory, or specified R scripts


Description

Look for all R scripts under a directory (using the pattern "[.][RrSsQq]$"), then tidy them with tidy_source(). If successful, the original scripts will be overwritten with reformatted ones. Please back up the original directory first if you do not fully understand the tricks used by tidy_source(). tidy_file() formats scripts specified by file names.

Usage

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

tidy_file(file, ...)

Arguments

path

The path to a directory containning R scripts.

recursive

Whether to recursively look for R scripts under path.

...

Other arguments to be passed to tidy_source().

file

A vector of filenames.

Value

Invisible NULL.

Author(s)

Yihui Xie (tidy_dir) and Ed Lee (tidy_file)

See Also

Examples

library(formatR)

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

formatR

Format R Code Automatically

v1.10
GPL
Authors
Yihui Xie [aut, cre] (<https://orcid.org/0000-0003-0645-5666>), Ed Lee [ctb], Eugene Ha [ctb], Kohske Takahashi [ctb], Pavel Krivitsky [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.