Description Usage Arguments Value See Also Examples
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
/
.
1 2 3 | 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.
1 2 3 4 5 6 7 8 9 10 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.