The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: R Source Code Formatter
Version: 0.1.1
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 "/".
Depends: R (≥ 3.2.2)
License: GPL-3
LazyData: true
Imports: formatR (≥ 1.2.1)
Suggests: testthat
URL: https://github.com/evolutics/RFormatter
BugReports: https://github.com/evolutics/RFormatter/issues
RoxygenNote: 5.0.1
NeedsCompilation: no
Packaged: 2016-05-12 18:08:43 UTC; fischebe
Author: Benjamin Fischer [aut, cre]
Maintainer: Benjamin Fischer <benjamin.fischer@evolutics.info>
Repository: CRAN
Date/Publication: 2016-05-13 00:44:27

Formats R source code.

Description

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 /.

Usage

format_R_source_code(source, formatR_arguments = list(),
  remove_trailing_whitespace = TRUE, spaced_operators = c("/", "%%",
  "%/%", ":", "^"))

Arguments

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 tidy_source.

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.

Value

String with formatted source code.

See Also

tidy_source

Examples


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)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.