Read and write the facts that hold for a whole column: what it estimates, which percentage base
it rests on, which reference it is compared to, how it is coloured, and how its confidence
interval was built. They are stored on the vector, not on the table, so a column keeps them when
it is extracted, renamed or piped through dplyr.
fmt_attr() reaches any of them by name — these are the readable way to address one you know.
tab_columns() shows them all, for every column of a table at once.
Usage
get_scale(x, ...)
set_scale(x, scale)
get_pct_type(x, ...)
set_pct_type(x, pct_type)
is_totcol(x, ...)
as_totcol(x, totcol = TRUE)
get_comp_all(x, replace_na = TRUE)
set_comp_all(x, comp_all = FALSE)
get_ref_type(x, ...)
set_ref_type(x, ref)
set_diff_type(x, ref)
get_col_var(x, ...)
set_col_var(x, col_var)
get_col_group(x, ...)
get_model_family(x, ...)
set_model_family(x, model_family)
get_ci_method(x, ...)
is_refcol(x, ...)
as_refcol(x, refcol = TRUE)
get_color(x, ...)
get_color_bg(x, ...)
get_color_signif(x, ...)
set_color(x, color)
set_color_signif(x, color_signif)Arguments
- x
The object to test, to get a field in, or to modify.
- ...
In
fmt(), it exists only for the arguments retired in tabxplor 2.0.0:typeis translated intoscale+pct_type(seetabxplor-type),ci_typegets an error naming its replacement. In the accessor methods below, to add arguments in the future.- scale
What the column estimates, as a single string (an attribute, not a field): one key into the declared library of estimate scales. It says which field holds the estimate, what its null value is, whether the scale is additive or multiplicative, and which colour ladder it reads.
"level_n": counts"level_pct": percentages (pct_typesays of what)"level_mean": means (from numeric variables)"points": a difference between two percentages, in percentage points"mean_diff": a difference between two means, in the outcome's own units"raw_diff": a regression coefficient / marginal effect in the outcome's units"pct_ratio","mean_ratio": the ratio of two percentages / two means"odds_ratio": a multiplicative effect (odds ratio, risk ratio, rate ratio)"log_coef": a link-scale coefficient (a log-odds, a log-rate)"mixed": what binding columns of unlike scales collapses to
- pct_type
For a percentage column, what the percentage is a percentage OF, and hence which axis its reference lies on (as a single string):
"row","col","all"(frequencies by subtable / group, i.e. bytab_vars),"all_tabs"(frequencies for the whole table), or"none"(counts, means, coefficients).- totcol
TRUEwhen the vector is a total column- replace_na
By default,
get_comp_alltakes NA in comparison level to be aFALSE(=comparison at subtables/groups level). Set toFALSEto avoid this behavior.- comp_all
FALSEwhen the comparison level is the subtable/group,TRUEwhen it is the whole table- ref
The type of difference of the vector. Cf.
tab.- col_var
The name of the
col_varused to calculate the vector- model_family
For regression tables (
tab_reg): the column's model family ("binomial","gaussian","poisson","multinomial","ordinal"), as a single string. Empty ("") on cross-tables. Lets a table mix several outcomes with different families, each column keeping its own effect wording.- refcol
TRUEwhen the vector is a reference column- color
The colour measure, as a single string — how a cell's value is compared to colour it (significance is handled separately by
color_signif):"no": no colors are printed."diff"("difference"): the cell's difference from the reference (a total, or the first cell whenref = "first") — percentage points for factors, a standardized difference for means."ratio": the ratio to the reference (relative risk for percentages, mean ratio)."or"("odds_ratio"): the odds ratio, for row/col percentages."contrib": the cell's contribution to the table's variance. Undercolor_signif = "guaranteed_effect"it switches to the absolute adjusted standardized residual — seetab."adjustment"/"between_groups": the twotab_regmeasures, which compare a cell to another column rather than to a reference row. A hand-built column may carry them, provided it fills theobsfield they score.
The value is validated and normalised: every accepted spelling — the discipline's acronyms included (
"RD","RR","IRR","RoM","OR"and their lowercase twins) — is stored as its canonical measure name, and an unknown one is an error. The tabxplor 1.x combined strings"diff_ci"/"after_ci"still work but are superseded by thecolor+color_signifpair; here they resolve to their measure half only, so pass the significance policy throughcolor_signif.- color_signif
How significance gates the color, as a single string (
"ignore"/"grey_non_signif"/"guaranteed_effect"). Seetab.
Value
A getter returns the stored value — its declared default where the attribute was never
set ("" for a name, FALSE for a flag, NA where there is none) — and answers once per
fmt column when given a data.frame. A setter returns the modified fmt vector.
Functions
get_scale(): get the estimate scale of fmt columns (atfmtlevel ortablevel)set_scale(): set the estimate scale attribute of afmtvectorget_pct_type(): get which kind of percentage fmt columns hold (atfmtlevel ortablevel)set_pct_type(): set the percentage-type attribute of afmtvectoris_totcol(): test function for total columns (atfmtlevel ortablevel)as_totcol(): set the "totcol" attribute of afmtvectorget_comp_all(): get comparison level of fmt columnsset_comp_all(): set the comparison level attribute of afmtvectorget_ref_type(): get differences type of fmt columns (atfmtlevel ortablevel)set_ref_type(): set the reference attribute of afmtvector — which row or column a comparison is made against. It is the writer of the attributeget_ref_type()reads.set_diff_type():Use
set_ref_type(), which shares its stem with the getterget_ref_type()and with therefattribute both of them address.get_col_var(): get names of column variable of fmt columns (atfmtlevel ortablevel)set_col_var(): set the "col_var" attribute of afmtvectorget_col_group(): get the sub-population of fmt columns (atfmtlevel ortablevel)get_model_family(): get the regression model family of fmt columns (atfmtortablevel)set_model_family(): set the "model_family" attribute of afmtvector (the per-column regression family, "" on crosstabs)get_ci_method(): get the interval method of fmt columns (atfmtlevel ortablevel)is_refcol(): test function for reference columns (atfmtlevel ortablevel)as_refcol(): set the "ref_col" attribute of afmtvectorget_color(): get color (atfmtlevel ortablevel)get_color_bg(): get the background-channel color measure (NAwhen there is none)get_color_signif(): get the significance policy ("ignore"/"grey_non_signif"/"guaranteed_effect")set_color(): set the "color" attribute of afmtvectorset_color_signif(): set the significance policy attribute of afmtvector
See also
fmt_attr() to address an attribute by name; tab_columns() for a whole table;
fmt() for what every attribute means; fmt_fields for the per-cell values.