Coloured Formatting for Columns

Provides 'pillar' and 'colonnade' generics designed for formatting columns of data using the full range of colours provided by modern terminals.


pillar

Lifecycle:stable R buildstatus Coveragestatus CRANstatus

pillar provides tools for styling columns of data, artfully using colour and unicode characters to guide the eye.

Installation

# pillar is installed if you install the tidyverse package:
install.packages("tidyverse")

# Alternatively, install just pillar:
install.packages("pillar")

Usage

pillar is a developer-facing package that is not designed for end-users. It powers the print() and format() methods for tibbles. It also and defines generics and helpers that are useful for package authors who create custom vector classes (see https://github.com/krlmlr/awesome-vctrs#readme for examples) or custom table classes (like dbplyr or sf).

library(pillar)

x <- 123456789 * (10^c(-3, -5, NA, -8, -10))
pillar(x)
#> <pillar>
#>       <dbl>
#> 123457.    
#>   1235.    
#>     NA     
#>      1.23  
#>      0.0123

tbl_format_setup(tibble::tibble(x))
#> <pillar_tbl_format_setup>
#> <tbl_format_header(setup)>
#> # A tibble: 5 × 1
#> <tbl_format_body(setup)>
#>             x
#>         <dbl>
#> 1 123457.    
#> 2   1235.    
#> 3     NA     
#> 4      1.23  
#> 5      0.0123
#> <tbl_format_footer(setup)>

Custom vector classes

The primary user of this package is tibble, which lets pillar do all the formatting work. Packages that implement a data type to be used in a tibble column can customize the display by implementing a pillar_shaft() method.

library(pillar)

percent <- vctrs::new_vctr(9:11 * 0.01, class = "percent")

pillar_shaft.percent <- function(x, ...) {
  fmt <- format(vctrs::vec_data(x) * 100)
  new_pillar_shaft_simple(paste0(fmt, " ", style_subtle("%")), align = "right")
}

pillar(percent)
#> <pillar>
#> <percent>
#>       9 %
#>      10 %
#>      11 %

See vignette("pillar", package = "vctrs") for details.

Custom table classes

pillar provides various extension points for customizing how a tibble-like class is printed.

tbl <- vctrs::new_data_frame(list(a = 1:3), class = c("my_tbl", "tbl"))

tbl_sum.my_tbl <- function(x, ...) {
  c("Hello" = "world!")
}

tbl
#> # Hello: world!
#>       a
#>   <int>
#> 1     1
#> 2     2
#> 3     3

See vignette("extending", package = "pillar") for a walkthrough of the options.


Code of Conduct

Please note that the pillar project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("pillar")

1.11.1 by Kirill Müller, a year ago


https://pillar.r-lib.org/, https://github.com/r-lib/pillar


Report a bug at https://github.com/r-lib/pillar/issues


Browse source code at https://github.com/cran/pillar


Authors: Kirill Müller [aut, cre] (ORCID: , Hadley Wickham [aut] , RStudio [cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, glue, lifecycle, rlang, utf8, utils, vctrs

Suggests bit64, DBI, debugme, DiagrammeR, dplyr, formattable, ggplot2, knitr, lubridate, nanotime, nycflights13, palmerpenguins, rmarkdown, scales, stringi, survival, testthat, tibble, units, vdiffr, withr


Imported by Andromeda, FeatureExtraction, IDEAFilter, OlinkAnalyze, REDCapTidieR, STATcubeR, adverbial, aftables, aplot, bench, bioseq, bupaR, cards, cleaner, collateral, cubelyr, dartR.popgen, datascan, dataset, dbplyr, dials, dibble, distributional, dplyr, duckplyr, dyadMLM, easycensus, edibble, egor, epiparameter, era, eye, finalfit, ggdag, glyrepr, googledrive, gratia, groupr, icecream, impactr, incidence2, isotracer, japanstat, jpcity, jpgrid, jpstat, keyed, manynet, markovmix, maskr, matrixset, mildsvm, mlstats, navigatr, outstandR, palette, palettes, parsermd, parsnip, partialised, partition, parttime, phinterval, pmxcode, posterior, probably, prt, rayrender, rayvertex, rbiom, readtext, repr, reviser, riskmetric, rsample, sdtm.oak, seekr, skimr, statim, stickyr, stratigraphr, supernova, tabxplor, taxa, tbl.now, text2map, tibble, tibbletime, tidycomm, tidydfidx, tidyfun, tidygraph, tidyseurat, tidysq, tidysynthesis, tidytable, tidytree, tidyverse, timbr, timeplyr, trending, unpivotr, versus, vitae, whippr, wikkitidy, workflowsets, xlr, xmap, yamlet.

Suggested by AMR, NHSRplotthedots, NeEDS4BigData, a5R, adj, arrow, bignum, blob, clock, codyn, datey, decimal, dialr, dm, errors, fabletools, feasts, fs, ggbreak, graphvec, haven, hms, icons, imgrec, ipaddress, irt, lobstr, mixtime, nanoparquet, pdqr, pkgcache, pkgsearch, ps, quantities, reticulate, retroharmonize, rhub, ricu, rimu, rlang, rskey, rversions, rxode2, schmear, sf, shide, shinyInvoice, tensorflow, tf, tidyLPA, tsitter, units, vctrs, weibulltools, zip.


See at CRAN