sprinkles

0th

Percentile

Define Customization to a Table

Customizations to a dust table are added by "sprinkling" with a little extra fairy dust. Sprinkles are a collection of attributes to be applied over a subset of table cells. They may be added to any part of the table, or to the table as a whole.

Usage
sprinkle(rows = NULL, cols = NULL, ..., part = c("body", "head", "foot",
"interfoot", "table"))

sprinkle_print_method(print_method = c("console", "markdown", "html", "latex"))

Arguments
rows
A numeric vector specifying the rows of the table to sprinkle. See details for more about sprinkling.
cols
A numeric (or character) vector specifying the columns (or column names) to sprinkle. See details for more about sprinkling.
...
named arguments, each of length 1, defining the customizations for the given cells. See "Sprinkles" for a listing of these arguments.
part
A character string denoting which part of the table to modify.
print_method
A character string giving the print method for the table.
Details

Sprinkling is done over the intersection of rows and columns. If rows but no columns are specified, sprinkling is performed over all columns of the given given rows. The reverse is true for when columns but no rows are specified. If neither columns nor rows are specified, the attribute is applied over all of the cells in the table part denoted in part.

Whenever part = "table", rows and columns are ignored and the attributes are applied to the entire table.

If at least one of border, border_thickness, border_units, border_style or border_color is specified, the remaining unspecified attributes assume their default values.

The sprinkles bg and bg_pattern may not be used together.

A more detailed demonstration of the use of sprinkles is available in vignette("pixiedust", package = "pixiedust")

Sprinkles

The following list describes the valid sprinkles that may be defined in the ... dots argument. All sprinkles may be defined for any output type, but only sprinkles recognized by that output type will be applied. For a complete list of which sprinkles are recognized by each output type, see vignette("sprinkles", package = "pixiedust").

• bg
{A character string denoting the color for the background. See "Colors".} bg_pattern{This is one of the few exceptions to the length 1 rule. This accepts a vector of any length. Background colors are recycled in a pattern. See "Colors". If left unspecified but bg_pattern_by is specified, this will default to c("white", "gainsboro").} bg_pattern_by{A character string denoting if the background pattern is recycled over rows or columns. Accepts either "rows", or "columns" with partial matching and defaults to "rows". If bg_pattern is provided, bg_pattern_by is assumed, meaning it is not necessary to explicitly define bg_pattern_by unless changing an existing or default setting.} bold{Logical value. If TRUE, text is rendered in bold.} border_collapse{Logical. Defaults to TRUE. This element is only applicable to part = "table" and will be applied to the table regardless the value of part in the call.} border{This is one of the few exceptions to the length 1 rule. Accepts values "left", "right", "top", "bottom", and "all" with partial matching. The border will be added to the sides indicated.} border_thickness{A numeric value denoting the thickness of the border. Defaults to 1.} border_units{A character string taking any one of the values "px" or "pt" with partial matching. Defaults to "px".} border_style{A character string taking any one of the values "solid", "dashed", "dotted", "double", "groove", "ridge", "inset", "outset", "hidden", or "none". Defaults to "solid".} border_color{A character string denoting the color for the border. See "Colors".} fn{A function to apply to values in cells. The function should be an expression that acts on the variable value. For example, quote(round(value, 3)).} font_color{A character string denoting the color of the font. See "Colors".} font_size{A numeric value denoting the size of the font.} font_size_units{A character string giving the units of the font size. Accepts values "px", "pt", "%", and "em". Defaults to "px".} halign{A character string denoting the horizontal alignment. Accepts any one of the values "left", "center", or "right", with partial matching.} height{A numerical value giving the height of the cells.} height_units{A character string giving the units for the height argument. Accepts "px" and "%". Defaults to "px".} italic{Logical value. If TRUE, text is rendered in italics.} pad{A numerical value giving the cell padding in pixels.} rotate_degree{A numerical value that determines the angle of rotation in the clockwise direction. Use negative values to rotate counter clockwise.} round{A numerical value for the number of decimal places to which numerical values are rounded. This can also be accomplished through the fn argument, but this argument makes it a bit easier to do.} valign{A character string giving the vertical alignment for the cells. Accepts the values "top", "middle", or "bottom" with partial matching.} width{A numerical value giving the width of the cells.} width_units{A character string giving the units for the width argument. Accepts "px" and "%". Defaults to "px".}

Colors

Color specifications accept X11 color names ("orchid"), hexidecimal names ("#DA70D6"), rgb names ("rgb(218 112 214)"), and rgba (rgb+alpha transparancy; "rgba(218, 112, 214, .75)"). Refer to https://en.wikipedia.org/wiki/Web_colors#X11_color_names.

sprinkle_colnames for changing column names in a table.

Aliases
• sprinkle
• sprinkle_print_method
• sprinkles
Examples
x <- dust(lm(mpg ~ qsec + factor(am), data = mtcars))
x + sprinkle(cols = 2:4, round = 3) +
sprinkle(cols = 5, fn = quote(pvalString(value))) +
sprinkle(rows = 2, bold = TRUE)
Documentation reproduced from package pixiedust, version 0.1.1, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.