Learn R Programming

tergo

Why tergo?

There is plenty of formatting libraries for R. Just to name a few:

Unfortunately, all of them suffer from one major drawback. They are slow. If you care about speed and efficiency of your styling tool, and not so much about the full-blown configurability, you should use tergo. Some use-cases include:

  • Save money on your CI infrastructure by checking the style with tergo instead of slow running alternatives. Save tens of hours on your monthly bill!
  • You are developing a user interface that needs to style the code for the user to see and other styling libraries don't cut it in terms of speed and efficiency.

tergo is Faster than Blink of an Eye. First run is more x100 faster or for bigger repositories even x1000 faster than other available solutions.

Yes, tergo is there but it takes less than 0.1 seconds so is not visible!!!

Benchmarking code is available in data-raw/bench.R on Github.

Installation

From Github sources

Requires Rust tooling:

  • rustup
  • cargo
if (!require(remotes)) {
  install.packages("remotes")
}
remotes::install_github("kpagacz/tergo@latest", subdir = "antidotum/tergo")

From R-Universe

Does not require Rust tooling, because R-Universe builds binaries.

install.packages('tergo', repos = c('https://kpagacz.r-universe.dev', 'https://cloud.r-project.org'))

Usage

See the R manual for the reference.

To style your package, run:

tergo::style()

Configuration

TOML file

tergo reads the configuration from a TOML file (tergo.toml) in your package root. See the library documentation for possible values and their explanation.

As an argument to styling functions

The styling functions accept a configuration argument that lets you modify the styling behaviour without a configuration file.

The keys and the possible values are the same as in the TOML file. See the library documentation for possible values and their explanation.

Copy Link

Version

Install

install.packages('tergo')

Monthly Downloads

152

Version

0.1.9

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Konrad Pagacz

Last Published

April 11th, 2025

Functions in tergo (0.1.9)

style_pkg_addin

Style the current package (RStudio addin)
style_text

Style text
truncate_error

Truncate the error message
style_selection_addin

Style the selected text (RStudio addin)
style_active_file_addin

Style the active file (RStudio addin)
style_file

Style a file
get_default_config

Get the default configuration
style

Style a package
style_pkg

Style a package
format_code

Format code
get_config

Parse the config file and return the configuration
is_in_ignored_paths

Check whether a path is in ignored paths
check_rstudioapi

Check for required RStudio API package
style_file_internal

Style a file internal
tergo-package

A library to make your source code pretty.