Conditional Formatting in Data Frames
Overview
Apply and visualize conditional formatting to data frames in R. It renders a data frame with cells formatted according to criteria defined by rules, using a tidy evaluation syntax. The table is printed either opening a web browser or within the 'RStudio' viewer if available. The conditional formatting rules allow to highlight cells matching a condition or add a gradient background to a given column. This package supports both 'HTML' and 'LaTeX' outputs in 'knitr' reports, and exporting to an 'xlsx' file.
Breaking changes
- Drop the
magrittrdependency and the%>%pipe operator it re-exported (part of #43). condformat now requires R >= 4.1 and its own examples, tests and vignette use the native base R pipe (|>) instead. If your code relied onlibrary(condformat)making%>%available, eitherlibrary(magrittr)yourself or switch to|>.
Dependencies
- Move
gridExtra,gtable,openxlsxandrmarkdownfromImportstoSuggests. These are each only needed for one specific, optional output path:openxlsxforcondformat2excel()/condformat2excelsheet(),gridExtra/gtableforcondformat2grob()/theme_grob(), andrmarkdownfor LaTeX/PDF output viaknit_print(). If you only ever use condformat's default HTML/RStudio-viewer printing, you no longer need to install any of these. Calling one of the functions above without the corresponding package installed now stops with a clearinstall.packages(...)hint instead of a generic "there is no package called" error, or (forrmarkdown) failing deep insideknit_print().
Show all changes in 0.11.0Hide the rest of the changes in 0.11.0
- Bump the minimum required version of all versioned dependencies to the release that was current about a year ago, rather than today's exact latest release, so users aren't forced onto a brand new patch just to install condformat (part of #43):
dplyr(>= 1.1.4),gtable(>= 0.3.6),htmlTable(>= 2.4.3),htmltools(>= 0.5.8.1),knitr(>= 1.50),openxlsx(>= 4.2.8),rmarkdown(>= 2.29),rlang(>= 1.1.6),scales(>= 1.4.0),tibble(>= 3.3.0),tidyselect(>= 1.2.1),shiny(>= 1.11.1),testthat(>= 3.2.3) andvdiffr(>= 1.0.8).gridExtra's floor (>= 2.3) is unchanged, as that release is still the latest on CRAN as of a year ago.
New features
rule_fill_bar()is now supported in Excel output, rendered using Excel's own native data bar conditional formatting (coloured withlow) instead of being dropped with an "unsupported rule" warning. This only applies whenexpressionis left at its default (or explicitly.col), since Excel data bars always reflect a cell's own displayed value against a range and can't replicate an arbitrary customexpression; in that case the data bar itself is skipped (with a warning) but the flatbackground/na.valuecell colours are still applied, as before.- Export
condformat2excelsheet(), which writes a condformat table into a worksheet of anopenxlsxworkbook you're already building, without creating or saving the workbook itself (closes #25). Its docs show how to combine condformat's own cell styling with your ownopenxlsx::addStyle()calls (e.g. a number format) viastack = TRUE, sinceaddStyle()replaces existing styles by default. - Add a
.colpronoun usable in theexpressionargument ofrule_fill_discrete(),rule_fill_gradient(),rule_fill_gradient2(),rule_fill_bar(),rule_text_bold(),rule_text_color()andrule_css(). Whencolumnsselects more than one column,.colis bound to each column's own values in turn, so a single rule call can format several columns based on each one's own condition (closes #19):rule_fill_discrete(c(Sepal.Length, Sepal.Width), .col > 3)is now equivalent to chaining the rule once per column.expressionnow also defaults to.colwhen omitted, replacing the previous behaviour of silently using only the first selected column (with a warning) when no expression was given for a multi-column selection.
Fixes
- Fix
condformat2excel()/condformat2excelsheet()silently discarding any pre-existing cell formatting on every export — including a Date column's automatic format fromopenxlsx::writeData()— even for cells with no condformat rule applied to them.condformat2excelsheet()'s own styling now usesstack = TRUEinternally, so it merges with, rather than replaces, formatting that was already there (related to #25). - Fix
lockcells = TRUEbeing ignored (or worse, unlocking cells) for LaTeX and grob/gtable output inrule_fill_discrete(),rule_fill_gradient(),rule_fill_gradient2(),rule_text_bold()andrule_text_color(). HTML and Excel output were not affected. - Fix
theme_htmlTable()discarding arguments accumulated from earliertheme_htmlTable()calls in the same pipeline, due to a%in%check against list values instead of list names. - Fix
rule_fill_bar()'sna.valuenever being applied tobackground-colorin HTML output: the CSS mask used to gate that assignment already excluded NA cells, so the assignment was dead code. - Fix
rule_fill_bar()erroring in grob/gtable output when a value rescaled to exactly 0% of the bar width (colorRampPalette()can't return zero colours); such cells now render with just the background colour. - Fix
rule_fill_bar()'slockcells = TRUEnot protecting NA cells from later CSS/HTML rules, and not protecting any cell (NA or not) from later grob/gtable rules: the grob/gtable renderer painted every targeted cell unconditionally and never checked incoming lock state at all. - Fix
rule_text_bold(),rule_text_color()andrule_css()erroring whenexpressionevaluates to a single (scalar) value on a table with more than one row, unlikerule_fill_discrete(),rule_fill_gradient(),rule_fill_gradient2()andrule_fill_bar(), which already recycled such values to every row.
Other
- Fix the bundled shiny example (
inst/shinyexample/):requireNamespace()now passesquietly = TRUE, so it no longer prints a package-startup message every time the optionalcolourpickerdependency isn't installed. Also modernised the legacyshinyUI()/shinyServer()wrappers to the currentui <- .../server <- function(input, output) {...}style.
From NEWS.md in the release
Install
Health
NOTER code for possible problemsr-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-devel-windows-x86_64
Found calls to structure() using deprecated special names: condformat/tests/testthat/test-render-html.R (.Dim: 2, .Dimnames: 2) '.Dim' should be changed to 'dim'. '.Dimnames' should be changed to 'dimnames'.
- NOTE8 OK, 5 NOTENow
- NOTE11 OK, 2 NOTE2026-07-16
- OK14 OK2026-03-10
Documentation
- Help pages
- 27
- Examples that run
- 95%19 run in a plain check · 1 never run
- Exported functions with examples
- 76%
- Documented parameters
- 100%
- Return-value docs
- 56%
- Help pages citing references
- 0%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 2
- Median days to close, 50 most recently updated closed PRs
- 0
11 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/zeehio/condformat on 2026-10-25.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
The repository owner accepts GitHub Sponsors
GitHub Pages site last deployed 2026-07-10 · The repository has a site deploy workflow
pkgdown site last built 2026-07-10
Show all practicesHide 2 practices
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-07-07Pull request it wrote: opened by a project memberCommits: 37 by its own account
Dependencies
Code & Tests
People & History
Maintainer since 0.2.0 (2016)
Pick two releases to compare their code metrics.
- 0.11.0Latest
- RR 4.6.0 released · 2026-04-24
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- 0.10.12023-10-08 · diff ↗
- RR 4.3.0 released · 2023-04-21
- 0.10.02022-11-26 · diff ↗
- RR 4.2.0 released · 2022-04-22
- RR 4.1.0 released · 2021-05-18
- 0.9.02020-05-14 · diff ↗ ·
removed 8 exports
rule_fill_discrete_, rule_fill_gradient2_, rule_fill_gradient2_old, rule_fill_gradient_, rule_fill_gradient_old, show_columns_, show_rows_, uq - RR 4.0.0 released · 2020-04-24
- RR 3.6.0 released · 2019-04-26
- 0.8.02018-10-29 · diff ↗ ·
added 11 exports
cf_field_to_css, cf_field_to_gtable, cf_field_to_latex, condformat2grob, rule_fill_bar, rule_text_bold, rule_text_color, theme_caption, theme_grob, theme_htmlWidget, theme_kable - RR 3.5.0 released · 2018-04-23
- 0.7.0
- 0.6.0
Show 6 earlier eventsHide 6 earlier events
- RR 3.4.0 released · 2017-04-21
- 0.5.0
- 0.4.0
- RR 3.3.0 released · 2016-05-03
- 0.2.02016-03-07
- RR 3.2.0 released · 2015-04-16
Package metadata
- First published
- 2016-03-07
- Total releases
- 10 / 10 yrs
- License
- BSD_3_clause + file LICENSE OSI
- Minimum R
- ≥ 4.1
- Download size
- 128 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("condformat")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-26, which the citation names so these numbers can be found later. More on citing and the projects behind them.