The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
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[@]metanet.ch.

R Formatter

Build status CRAN version

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

The following features are added to formatR.

Installation

In R, run

> install.packages("RFormatter")

Usage

Try

> RFormatter::format_R_source_code("if (b) { f() }")
> RFormatter::format_R_source_code("p = 2", list(arrow = TRUE))
> RFormatter::format_R_source_code("(k/n)^x", spaced_operators = c("/"))

Get more help with

> ?RFormatter::format_R_source_code

Command-Line Utility

To format a source file source.R via a command-line interface, do the following. Warning: the original file is overwritten, so better back it up first! Use this at your own risk. Run

$ Rscript [utility] source.R

where [utility] is the path given by

> system.file("exec", "utility.R", package = "RFormatter")

Have a look at Yihui Xie’s formatR.

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.