Format R Code Automatically

View project onGitHub

This package can be used to reformat R code: spaces and indent will be added to R code automatically, so that the code will be more human-readable and tidy. This package also provides a GUI (by gWidgets) to format R source code.


To install from CRAN, use

You can install the stable version on CRAN:


Or install the development version from RForge:

install.packages('formatR', repos = '', type = 'source')

Documentation and Examples

The workhorse in this package is the function tidy.source(). See the Wiki for usage and some examples.