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

tidy_dir {formatR} | R Documentation

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

### Description

`tidy_dir()` 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 used by `tidy_source`. `tidy_file()` formats specified R scripts.

### Usage

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

    tidy_file(file, ...)

### Arguments

`path` | the directory
`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

`tidy_source`

### Examples

    library(formatR)

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

[Package formatR version 1.5 Index]