Learn R Programming

Introduction to condformat

Sergio Oller 2022-11-26

condformat renders a data frame in which cells in columns are formatted according to several rules or criteria.

Browse source code

Checkout the code and browse it at https://github.com/zeehio/condformat.

How to install condformat:

Dependencies

If you want to use the PDF output you will need the xcolor LaTeX package. Either use the full texlive distribution, or install latex-xcolor on Debian and derivatives.

Package installation

  • From CRAN:

    install.packages("condformat")
  • To install the latest development version:

    remotes::install_github("zeehio/condformat")

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(c(Sepal.Length, Species), Species == "versicolor") %>%
  rule_text_color(Sepal.Length,
                  expression = ifelse(Species == "setosa", "yellow", "")) %>%
  rule_fill_bar(Petal.Width, limits = c(0, NA)) %>%
  theme_grob(rows = NULL) %>%
  condformat2grob()

This example covers most of the condformat rules.

Rules and output engine support

RuleHTMLLaTeXgtableExcel
rule_fill_discreteXXXX
rule_fill_gradientXXXX
rule_fill_gradient2XXXX
rule_text_colorXXXX
rule_text_boldXXXX
rule_fill_barXX
rule_cssX

Copy Link

Version

Install

install.packages('condformat')

Monthly Downloads

853

Version

0.10.0

License

BSD_3_clause + file LICENSE

Issues

Pull Requests

Stars

Forks

Last Published

November 26th, 2022

Functions in condformat (0.10.0)

rule_text_bold

Use bold text if a condition is met
knit_print.condformat_tbl

Print method for knitr, exporting to HTML or LaTeX as needed
rule_text_color

Give a color to the text according to some expression
rule_css

Apply a CSS style property as a conditional formatting rule
theme_caption

Sets the caption of a condformat object
print.condformat_tbl

Prints the data frame in an html page and shows it.
rule_fill_bar

Fill column with a bar of a length proportional to a value
theme_grob

Customizes appearance of condformat object
show_columns

Selects the variables to be printed
show_rows

Selects the rows to be printed
rule_fill_gradient2

Fill column with sequential color gradient
theme_htmlTable

Customizes appearance of condformat object
theme_htmlWidget

Customizes appearance of condformat object
rule_fill_discrete

Fill column with discrete colors
theme_kable

Customizes appearance of condformat object
condformat2html

Converts the table to a htmlTable object
condformat2grob

Converts the table to a grid object
cf_field_to_css

How to export a cf_field to CSS
cf_field_to_gtable

How to export a cf_field to grob
condformat-shiny

Shiny bindings for condformat
cf_field_to_latex

How to export cf values to latex
condformat

Conditional formatting for data frames
condformat2widget

Converts the table to a htmlTableWidget
condformat2excel

Writes the table to an Excel workbook
condformat2latex

Converts the table to LaTeX code
rule_fill_gradient

Fill column with sequential colour gradient
%>%

Pipe operator