| Title: | paint data.frames summaries in colour |
|---|---|
| Description: | Provides an alternative to the print() methods provided by the authors of `data.frame` objects: `tibble`, `sf`, `data.table`, `data.frame`. |
| Authors: | Miles McBain [aut, cre] (ORCID: <https://orcid.org/0000-0003-2865-2548>) |
| Maintainer: | Miles McBain <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0 |
| Built: | 2026-06-16 07:21:05 UTC |
| Source: | https://github.com/milesmcbain/paint |
This function calls paint() repeatedly on a dataframe,
updating the rows shown in response to keypresses.
ipaint(df = .Last.value)ipaint(df = .Last.value)
df |
the dataframe to scroll through, defaults to |
It will only work in terminals supported by {keypress} - Not many!
Controls:
'l' or 'right arrow' forward 1 row
'h' or 'left arrow' backward 1 row
'enter' or 'escape' quit interactive painting
'b' backward 1 page of rows
'f' forward 1 page of rows
'G' jump to final page of rows
'g' jump to first page of rows
This function replaces the original paint methods for supported data.frame
sub classes with calls to paint() in the current session. The utility of
this is that paint() will be called whenever print() would, for example
at the end of an expression when coding interactively.
mask_print() unmask_print()mask_print() unmask_print()
This also makes paint usable with other tools that output to console e.g. {breakerofchains}.
If you really like paint() you could put paint::mask_print() in your .Rprofile.
By default a colourful reminder message is emitted whenever print methods are
replaced, which may not happen until the package that contains them is actually
loaded, e.g. after library(tibble). This can be disabled with options(paint_remind_mask_print = FALSE)
unmask_print(): the reverse operation to mask_print: return all print methods to defaults.
unpaint() A method for calling the default print functions once for a single object or .Last.value.
paint is an alternative print method of objects that are of class
data.frame. It has been described as a "pretty pillar::glimpse()", since it
also favours printing columns running horizontally.
paint(df, ...)paint(df, ...)
df |
the dataframe to paint |
... |
further arguments to class specific paint methods |
paint tries to be low noise by using colour instead of markup characters.
It also highlights important values like NA, NULL, NaN, and Inf.
Each supported sub-class of data.frame has a custom meta data header,
designed to show useful information for wrangling.
The appearance of the output can be customised with options:
paint_palette the palette to paint row colours with, defaults to
rainbow_6(), 6 standard ANSI colours that are supported in most terminals.
paint_n_rows the number of rows to print for each column. Defaults to the
number of colours in the paint_palette, but can be set higher for repeating sequences.
paint_max_width the maximum width of the output. 60 is the default. {paint} does not resize
based on terminal width by design.
paint_align_row_head = c("left", "center", "right"). How to align the column
title and type. Defaults to "left".
paint_dark_mode darken the paint_palette using crayon::blurred - not
supported in all terminals.
df invisibly. Text outputed printed to console.
unpaint() for calling the default print method on a dataframe
paint(mtcars)paint(mtcars)
paintpals
rainbow_6() viridis_6() brewer_set3_12() brewer_pastel1_8() brewer_pastel2_7() brewer_dark2_7() brewer_accent_7()rainbow_6() viridis_6() brewer_set3_12() brewer_pastel1_8() brewer_pastel2_7() brewer_dark2_7() brewer_accent_7()
{paint} paletteExported just for fun.
rainbow_text(msg)rainbow_text(msg)
msg |
a length one character vector (not length checked) to be coloured
using the palette set in the |
a character vector with ANSI colour codes embedded. use cat() to see the coloured message.
Attempt to transform chars in encodings we don't understand, rather than crash crayon.
sanitise_col(col)sanitise_col(col)
col |
the column to sanitise, a vector |
Miles McBain
If you're using paint() as your default print() for dataframes, you may
occasionally want to see an object printed using it's default method. This
function does that.
unpaint(df = .Last.value)unpaint(df = .Last.value)
df |
the object to print. |
Either supply the object as the df arg, or if it has just been painted, you
can call unpaint() with no arguments to print the .Last.value.
mask_print() to use paint() by default for dataframes in the current session over print().