tab_xl_confidential {tabxplor} | R Documentation |
Excel output for tabxplor tables with confidentiality rules.
Description
Excel output for tabxplor tables, with colors to show if counts
and percentages respect statistical confidentiality rules. Don't forget to provide
subtext = c("Source : description of the source of the data")
in tab
or tab_many
,
otherwise it is not possible to assess, for your reader, which confidentiality rules
applies. For the same reason, you must supply a description of all variables in
var_labels
.
Usage
tab_xl_confidential(
tabs,
path = NULL,
replace = NULL,
open = rlang::is_interactive(),
n_min = 5,
pct_max = 0.95,
recalculate_totcols = NULL,
var_labels = character(),
colnames_rotation = 0,
colwidth = 10,
sheets = "unique",
print_color_legend = TRUE,
titles,
hide_near_zero = "auto",
color_type = "text"
)
Arguments
tabs |
A table made with |
path , replace , open |
The name, and possibly the path, of the Excel file to
create (possibly without the .xlsx extension). Default path to temporary directory.
Set global option |
n_min |
The total count under which a column or row doesnt respect statistical confidentiality. Default to 5. |
pct_max |
The row or column percentage above which, knowing the column category, it becomes possible to guess the row category, or the other way round. Default to 0.95 (95%). |
recalculate_totcols |
By default, total columns are recalculated from counts if
there are many |
var_labels |
The description of all the variables, necessary to assess that
the tables don't break confidentiality rules, as a character vector of the type
|
colnames_rotation |
Rotate the names of columns to an angle (in degrees). |
colwidth |
The standard width for numeric columns, as a number. Default to 10. |
sheets |
The Excel sheets options :
|
print_color_legend |
Should the color legends be printed with the subtexts ? |
titles |
The titles of the different tables, as a character vector. When missing titles are given based on the names of the variables. |
hide_near_zero |
By default all cells displayed as 0 (even rounded)
turn pale grey, to make the distribution of empty cells (and other cells) more visible.
Provide a number to turn grey every cell below it. Set to |
color_type |
By default, the text is colored. Set to |
Value
The table(s) with formatting and colors in an Excel file, as a side effect.
Invisibly returns tabs
.
Examples
forcats::gss_cat |>
tab(race, marital, year, pct = "row", color = "diff",
subtext = c('Source : National Opinion Research Center, General Social Survey.')) |>
tab_xl_confidential(titles = "Marital status by race",
var_labels = c("marital" = "marital status", "race" = "race",
"year" = "year of survey"))