Quickstart

condformat prints a data frame with cells formatted according to several rules or criteria. It is integrated with the RStudio Viewer or a web browser, and it supports knitr and rmarkdown outputs using both HTML and PDF (\(\LaTeX\)) output formats. Other formats are not supported, although patches to enable them are welcome.

Basic syntax

Its syntax should be familiar to ggplot users, with tidy evaluation.

condformat(a_data_frame) %>%          # A data frame to print
  rule_fill_discrete(ColumnA) %>%     # Add formatting rules to the data frame
  rule_fill_gradient(ColumnB)

Example:

data(iris)
library(condformat)
condformat(iris[c(1:5,70:75, 120:125),]) %>%
  rule_fill_discrete(Species) %>%
  rule_fill_discrete(c(Sepal.Width, Sepal.Length),
                     expression = Sepal.Width > Sepal.Length - 2.25,
                     colours = c("TRUE" = "#7D00FF")) %>%
  rule_fill_gradient2(Petal.Length) %>%
  rule_text_bold(Sepal.Length, Species == "setosa") %>%
  rule_text_color(Sepal.Length, ifelse(Species == "setosa", "yellow", "")) %>%
  rule_fill_bar(Petal.Width, limits = c(0, NA))
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
6 5.6 2.5 3.9 1.1 versicolor
7 5.9 3.2 4.8 1.8 versicolor
8 6.1 2.8 4.0 1.3 versicolor
9 6.3 2.5 4.9 1.5 versicolor
10 6.1 2.8 4.7 1.2 versicolor
11 6.4 2.9 4.3 1.3 versicolor
12 6.0 2.2 5.0 1.5 virginica
13 6.9 3.2 5.7 2.3 virginica
14 5.6 2.8 4.9 2.0 virginica
15 7.7 2.8 6.7 2.0 virginica
16 6.3 2.7 4.9 1.8 virginica
17 6.7 3.3 5.7 2.1 virginica