Learn R Programming

formatR (version 1.14)

tidy_rstudio: Reformat R code in RStudio IDE

Description

If any R code is selected in the RStudio source editor, this function reformats the selected code; otherwise it reformats the current open file (if it is unsaved, it will be automatically saved).

Usage

tidy_rstudio(...)

Arguments

...

Arguments to be passed to tidy_source(), among which the indent argument will respect the value you set for the number of spaces for indentation in RStudio.

Examples

Run this code
if (FALSE) { # interactive()
formatR::tidy_rstudio()
formatR::tidy_rstudio(args.newline = TRUE)
}

Run the code above in your browser using DataLab