style_file

0th

Percentile

Style .R and/or .Rmd files

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

Aliases
  • style_file
Examples
# 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)
# }
Documentation reproduced from package styler, version 1.0.9000, License: GPL-3

Community examples

Looks like there are no examples yet.