Creates an xlsx report based on the result of
srv_prop_stats_crossing(). A sheet is created for each of the grp_var
entries.
Sheet names are taken from the grp_var_label variable and, if NA, from
grp_var. If the sheet name happens to be longer than 31 characters, it
will be truncated. It is advised to modify grp_var_label column as needed
before running the function.
Each sheet contains a table report for proportion statistics for
each of the sbj_var variables.
Usage
srv_prop_stats_xlsx(
prop_res,
file,
overwrite = FALSE,
overall = TRUE,
secondary_stats = c("percentage", "n"),
hide_stat_names = TRUE,
...
)Arguments
- prop_res
Result of
srv_prop_stats_crossing().- file
File to write report to.
- overwrite
If
TRUE, overwrite any existing file.- overall
Add overall column for subject variable stats? Default is
TRUE.- secondary_stats
Names of statistics to display in addition to index. Default is
c("percentage", "n"). Set to NULL if you only want to display index values.- hide_stat_names
Hide statistic names column? Default is
TRUE.- ...
Additional parameters passed to internal functions controlling styling of sheet cells (currently supported parameters are:
overall_percent_font_color,overall_fill_color,group_percent_font_color,header_font_color,header_fill_color,header_border_color,header_border_style,border_colorandborder_style)
Examples
if (FALSE) { # \dontrun{
data("ds_newsletter")
library(dplyr)
prop_res <-
ds_newsletter %>%
rename(s_region = Region) %>%
srv_prop_stats_crossing(c(s_race, s_region), s_age:s_hhincome) %>%
mutate(grp_var_label = case_when(
grp_var == "s_race" ~ "Race",
grp_var == "s_region" ~ "Region"
))
# all stats, keep stat names
srv_prop_stats_xlsx(prop_res, "prop_stats_all.xlsx",
hide_stat_names = FALSE,
overwrite = TRUE
)
# all stats, keep stat names, use alternative styling
srv_prop_stats_xlsx(
prop_res, "prop_stats_abomination.xlsx",
hide_stat_names = FALSE, overwrite = TRUE,
overall_percent_font_color = "pink", overall_fill_color = "black",
group_percent_font_color = "#fff000", header_font_color = "blue",
header_fill_color = "#aabbcc", header_border_color = "#000fff",
header_border_style = "dashed", border_color = "pink",
border_style = "thin"
)
# index + percent, dont display overall,
srv_prop_stats_xlsx(prop_res, "prop_stats_index_perc.xlsx",
overall = FALSE,
secondary_stats = "percentage",
overwrite = TRUE
)
} # }