Helper function to get the right formatting in the optional table in g_lineplot.
Source: R/g_lineplot.R
h_format_row.RdArguments
- x
(named
list)
list of numerical values to be formatted and optionally labeled. Elements ofxmust benumericvectors.- format
(named
characterorNULL)
format patterns forx. Names of theformatmust match the names ofx. This parameter is passed directly to thertables::format_rcellfunction through theformatparameter.- labels
(named
characterorNULL)
optional labels forx. Names of thelabelsmust match the names ofx. When a label is not specified for an element ofx, then this function tries to uselabelornames(in this order) attribute of that element (depending on which one exists and it is notNULLorNAorNaN). 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)