Title: | R Source Code Formatter |
---|---|
Description: | The R Formatter formats R source code. It is very much based on formatR, but tries to improve it by heuristics. For example, spaces can be forced around the division operator "/". |
Authors: | Benjamin Fischer [aut, cre] |
Maintainer: | Benjamin Fischer <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2025-02-17 03:14:07 UTC |
Source: | https://github.com/cran/RFormatter |
format_R_source_code
is very much based on
formatR, but tries to improve it by
heuristics. For example, spaces can be forced around the division operator
/
.
format_R_source_code(source, formatR_arguments = list(), remove_trailing_whitespace = TRUE, spaced_operators = c("/", "%%", "%/%", ":", "^"))
format_R_source_code(source, formatR_arguments = list(), remove_trailing_whitespace = TRUE, spaced_operators = c("/", "%%", "%/%", ":", "^"))
source |
String with source code to format. This not the filename of the source file. |
formatR_arguments |
List of arguments passed to
formatR via its
|
remove_trailing_whitespace |
Boolean: should horizontal whitespace at the end of lines be removed? |
spaced_operators |
Vector of strings with operators around which spaces are forced. |
String with formatted source code.
format_R_source_code("if (b) { f() }") format_R_source_code("if (b) { f()\n\nf() }") format_R_source_code("p = 2", list(arrow = TRUE, width.cutoff = 80)) format_R_source_code("(k/n)^x", spaced_operators = c("/")) ## Not run: format_R_source_code("f()", text = NULL) format_R_source_code("f()", output = TRUE) ## End(Not run)
format_R_source_code("if (b) { f() }") format_R_source_code("if (b) { f()\n\nf() }") format_R_source_code("p = 2", list(arrow = TRUE, width.cutoff = 80)) format_R_source_code("(k/n)^x", spaced_operators = c("/")) ## Not run: format_R_source_code("f()", text = NULL) format_R_source_code("f()", output = TRUE) ## End(Not run)