dust table are added by "sprinkling"
with a little extra pixie 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.sprinkle(x, rows = NULL, cols = NULL, ..., part = c("body", "head",
"foot", "interfoot", "table"))
sprinkle_print_method(x, print_method = c("console", "markdown", "html",
"latex"))
sprinkle_table(x, cols = NULL, ..., part = "table")... 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").
bgbg_patternbg_pattern_by is
specified, this will default to c("White", "Gray").}
bg_pattern_by"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.}
boldTRUE, text is rendered in bold.}
border_collapseTRUE.
This element is only applicable to
part = "table" and will be applied to the table regardless
the value of part in the call.}
border"left", "right", "top",
"bottom", and "all" with partial matching. The border will be added
to the sides indicated.}
border_thickness1.}
border_units"px" or "pt" with partial matching. Defaults
to "px".}
border_style"solid", "dashed", "dotted",
"double", "groove", "ridge", "inset",
"outset", "hidden", or "none". Defaults
to "solid".}
border_colorfnvalue. For
example, quote(round(value, 3)).}
font_colorfont_sizefont_size_units"px", "pt", "%",
and "em". Defaults to "pt". LaTeX formats only recognize
"pt" and "em", and other units specifications will be
coerced to "pt", which may result in an unexpected appearance.}
halign"left", "center", or
"right", with partial matching.}
heightheight_unitsheight argument. Accepts "px", "pt", "cm",
"in" and "%". Defaults to "pt". LaTeX formats
do not recognize "px" and this will be coerced to "pt" when
submitted for LaTeX output.}
italicTRUE, text is rendered in italics.}
longtableFALSE,
indicating that only one table is printed (default); TRUE that the table should be
split into multiple tables with the default number of rows per table (see "Longtable"); or a
positive integer indicating how many rows per table to include. All other values are
interpreted as FALSE.}
mergeTRUE, the cells indicated in
rows and cols are merged into a single cell. An error is
cast if the cells do not form an adjacent block. Specifying
merge_rowval or merge_colval without merge results
in an error; pixiedust is conservative and will not assume you
mean to merge cells--it must be explicitly declared.}
merge_rowvalrows. If no value is provided,
the smallest value of rows is used.}
merge_colvalcols. If no value is provided,
the smallest value of cols is used.}
na_stringNA) are to be represented in the table. Defaults to an
empty character string ("").}
padreplacerows and cols. Replacement
is always performed moving down columns first, then across rows from left to right.
The operating assumption is that the most frequent use of this argument will be
to replace entire columns.}
rotate_degreeroundfn argument, but this argument makes it a bit easier to do. In cases where
character values are indicated for rounding (such a a term name), no action is taken.
This means that `sprinkle(x, round=3)` would round all numerical values in a table to three
decimal places without affecting any true character values; there is no need to limit
the `round` sprinkle to known numerical values.}
valign"top", "middle", or "bottom"
with partial matching.}
widthwidth_unitswidth argument. Accepts "px", "pt", "cm",
"in" and "%". Defaults to "px". LaTeX formats
do not recognize "px" and this will be coerced to "pt" when
submitted for LaTeX output.}longtable feature is named for the LaTeX package used to break very large
tables into multiple pages.
When using the longtable=TRUE option, the default number of rows per table is 25 for
console, HTML, and markdown output. For LaTeX output, the number of rows is determined by
the LaTeX longtable package's algorithm. The number of rows per table only considers
the content in the body of the table. Consideration for the number of rows in the head and
foot are the responsibility of the user.
Whenever a table is broken into multiple parts, each part retains the table head. If any
interfoot is provided, it is appended to the bottom of each section, with the
exception of the last section. The last section has the foot appended."orchid"),
hexidecimal names ("#DA70D6"), rgb names ("rgb(218 112 214)"),
and rgba (rgb+alpha transparency; "rgba(218, 112, 214, .75)").
Refer to xcolor manual
(color
package included in your document preamble (\usepackage{color}).
Rmarkdown documents include the color package automatically. The
standard colors available in LaTeX are "white", "black", "red", "green",
"blue", "cyan", "magenta", and "yellow".
Additional colors may be made available using the LaTeX package xcolor.
To be consistent with color names used in the HTML tables, it is recommended
that you use the option \usepackage[dvipsnames]{xcolor} in your
preamble. Please note that color names in LaTeX are case-sensitive, but the
HTML names are not. If the ability to switch between output methods is
something you desire, you should adopt the capitalization used in the dvips
names (See page 38 of the xcolor manual;
[x11names] option to have the X11
color names available to you.
The LaTeX output will accept hexidecimal names ("#DA70D6") and
rgb names ("rgb(218 112 214)"), similar to the HTML colors described
above. However, transparency is not supported. If the transparency
value is provided, it is silently ignored.
Custom color definitions may also be defined by defining the color in the
preamble. The process for color definitions is described in the xcolor
documentation. Keep in mind that custom color designations in LaTeX output
will not transfer the other output formats..Rnw files, additional packages can be included with the
\usepackage{[package]} syntax. In markdown, additional packages
are included using header-includes: in the YAML front matter with
a line of the format \usepackage{[package]} for each package to
be used. Sprinkles that require additional packages, and the LaTeX packages
required, are listed below:
font_color \usepackage[dvipsnames]{xcolor}
bg, bg_pattern \usepackage[dvipsnames,table]{xcolor}
}part.
Whenever part = "table", rows and columns are ignored
and the attributes are applied to the entire table. This feature is not
yet implemented (2015-08-05) and may be removed, depending on how useful
it turns out to be.
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.
Other sprinkle pairings are height and height_units;
width and width_units; font_size and font_size_units;
bg_pattern and bg_pattern_by
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")
In sprinkle, when part = "table", the attributes are assigned to
the entire table. This is not yet active and may be removed entirely.
The sprinkle_table, sprinkles may be applied to the columns of multiple tables. Table
parts are required to have the same number of columns, but not necessarily the same number
of rows, which is why the rows argument is not available for the sprinkle_table.
In contrast to sprinkle, the part argument in sprinkle table will
accept multiple parts. If any of the named parts is "table", the sprinkle will be
applied to the columns of all of the parts.sprinkle_colnames for changing column names in a table.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)Run the code above in your browser using DataLab