| column_format | R Documentation |
This class is used to define the format of columns in tables, including the name, header, latex representation, a formatter function, and what the header abbreviates.
column_format(
name = character(0),
header = character(0),
latex = character(0),
formatter = function() NULL,
abbreviation = character(0)
)
name |
name of column |
header |
markdown representation of header name |
latex |
latex representation of header name |
formatter |
function that formats the column values. It should take a vector of values and return a character vector of formatted values. |
abbreviation |
what the header stands for, used by |
A column_format is an S7 object. Its properties are read and changed with
@ (e.g., R2@header, or R2@formatter <- my_function). Formats are
collected in a column_formats() object, in which each format is read,
added, or replaced with $ (e.g., column_formats()$p). The table
functions use a format for every column with the same name as the format.
column_format object
R2 <- column_format(
"R2",
header = "*R*^2^",
latex = "$R^2$",
formatter = \(x, accuracy = .01, ...) {
align_chr(x,
accuracy = accuracy,
trim_leading_zeros = TRUE,
...)
})
R2
R2@header
R2@formatter(c(.123, .45))
# Define an abbreviation in table notes
SS <- column_formats()$Sum_Squares
SS@abbreviation <- "sum of squares"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.