Helper function to get the right formatting in the optional table in g_lineplot
.
Source: R/g_lineplot.R
h_format_row.Rd
Arguments
- x
(named
list
)
list of numerical values to be formatted and optionally labeled. Elements ofx
must benumeric
vectors.- format
(named
character
orNULL
)
format patterns forx
. Names of theformat
must match the names ofx
. This parameter is passed directly to thertables::format_rcell
function through theformat
parameter.- labels
(named
character
orNULL
)
optional labels forx
. Names of thelabels
must match the names ofx
. When a label is not specified for an element ofx
, then this function tries to uselabel
ornames
(in this order) attribute of that element (depending on which one exists and it is notNULL
orNA
orNaN
). If none of these attributes are attached to a given element ofx
, then the label is automatically generated.
Examples
mean_ci <- c(48, 51)
x <- list(mean = 50, mean_ci = mean_ci)
format <- c(mean = "xx.x", mean_ci = "(xx.xx, xx.xx)")
labels <- c(mean = "My Mean")
h_format_row(x, format, labels)
#> My Mean V1
#> 1 50.0 (48.00, 51.00)
attr(mean_ci, "label") <- "Mean 95% CI"
x <- list(mean = 50, mean_ci = mean_ci)
h_format_row(x, format, labels)
#> My Mean Mean 95% CI
#> 1 50.0 (48.00, 51.00)