styler (version 1.0.9000)

style_file: Style .R and/or .Rmd files

Description

Performs various substitutions in the files specified. Carefully examine the results after running this function!

Usage

style_file(path, ..., style = tidyverse_style, transformers = style(...))

Arguments

path

A character vector with paths to files to style.

...

Arguments passed on to the style function.

style

A function that creates a style guide to use, by default tidyverse_style() (without the parentheses). Not used further except to construct the argument transformers. See style_guides() for details.

transformers

A set of transformer functions. This argument is most conveniently constructed via the style argument and .... See 'Examples'.

Value

Invisibly returns a data frame that indicates for each file considered for styling whether or not it was actually changed.

Warning

This function overwrites files (if styling results in a change of the code to be formatted). It is strongly suggested to only style files that are under version control or to create a backup copy.

See Also

Other stylers: style_dir, style_pkg, style_text, styler_addins

Examples

Run this code
# NOT RUN {
# the following is identical but the former is more convenient:
file <- tempfile("styler", fileext = ".R")
enc::write_lines_enc("1++1", file)
style_file(file, style = tidyverse_style, strict = TRUE)
style_file(file, transformers = tidyverse_style(strict = TRUE))
enc::read_lines_enc(file)
unlink(file)
# }

Run the code above in your browser using DataCamp Workspace