rfmt: Format R code using the 'rfmt' formatter

Description Usage Arguments Value Note

Description

This function allows the rfmt R source code formatting tool to be invoked from R. It applies rfmt to an R source file, the contents of the system clipboard, or to a character string.

Usage

1
rfmt(source.file, text, ..., opts = list(...))

Arguments

source.file

a character string giving the location of a file containing R source code. Not supplied if parameter text is given instead.

text

a character string containing R source code. Not supplied if source.file is given instead.

opts

options to rfmt, supplied as a named list.

...

options to rfmt. See options_rfmt for options and their defaults.

Value

If formatting a file, nothing (invisible(NULL)). If formatting a string, a character vector comprising the formatted code. If formatting the contents of the clipboard, a similar character vector, but rendered invisible; the formatted code is also output to the terminal (using cat).

Note

Input is taken from the clipboard if neither source.file nor text is supplied.


google/rfmt documentation built on May 17, 2019, 7:59 a.m.