formatdown

Formatting tools for R markdown documents.

Provides a small set of tools for formatting tasks when writing documents in R Markdown or Quarto Markdown. Works with outputs in html, pdf, docx and possibly others.

Usage

# Packages
library("formatdown")
library("data.table")

format_power()   Convert the elements of a numerical vector to character strings in which the numbers are formatted using powers-of-ten notation in scientific or engineering form and delimited for rendering as inline equations in an R Markdown document.

# Scientific notation
format_power(101100, digits = 4, format = "sci")
#> [1] "$1.011\\times{10}^{5}$"

# Engineering notation
format_power(101100, digits = 4, format = "engr")
#> [1] "$101.1\\times{10}^{3}$"

which, in an Rmd or qmd document, are rendered as

• Scientific notation: $$1.011\times{10}^{5}$$.
• Engineering notation: $$101.1\times{10}^{3}$$

Installation

Install from CRAN.

install.packages("formatdown")

The development version can be installed from GitHub.

install.packages("devtools")
devtools::install_github("graphdr/formatdown")

Contributing

To contribute to formatdown,

• Please clone this repo locally.
• Commit your contribution on a separate branch.
• If you submit a function, please use the checkmate package to include runtime argument checks and the tinytest package to write unit tests for your code. Save tests in the inst/tinytest/ directory.

To provide feedback or report a bug,

• Use the GitHub Issues page.
• Please run the package unit tests and report the results with your bug report. Any user can run the package tests by installing the tinytest package and running:
# Detailed test results
test_results <- tinytest::test_package("formatdown")
as.data.frame(test_results)

Participation in this open source project is subject to a Code of Conduct.