Make Google Sheets output of list experiment results
Source:R/list_render_sheets.R
list_render_sheets.RdTakes model results and puts them into formated output.
Usage
list_render_sheets(
statements_list,
wb = NULL,
file = NULL,
low_p = 0.75,
mid_p = 0.92,
high_p = 0.95,
colors_p = c((grDevices::colorRampPalette(c("#F9C8BB", "#EF5D36")))(3),
(grDevices::colorRampPalette(c("#C4E9DA", "#50BD90")))(3))
)
list_render_sheets_within(
statements_list_within,
wb = NULL,
low_p = 0.75,
mid_p = 0.92,
high_p = 0.95,
colors_p = c((grDevices::colorRampPalette(c("#F9C8BB", "#EF5D36")))(3),
(grDevices::colorRampPalette(c("#C4E9DA", "#50BD90")))(3))
)
list_render_sheets_between(
statements_list_between,
wb = NULL,
low_p = 0.75,
mid_p = 0.92,
high_p = 0.95,
colors_p = c((grDevices::colorRampPalette(c("#F9C8BB", "#EF5D36")))(3),
(grDevices::colorRampPalette(c("#C4E9DA", "#50BD90")))(3))
)Arguments
- statements_list
A list of results made with
list_statistics_bulk(). Names of the list elements should indicate the bundle or statement.- wb
Workbook object.
- file
xlsxname to save the workbook to. IfNULL, the function will return aWorkbookobject without creating a file- low_p
Numeric. Minimum probability value for which the first color from
colors_pargument will be assigned. Needs to take value between 0 and 1.- mid_p
Numeric. Minimum probability value for which the second color from
colors_pargument will be assigned. Needs to take value between 0 and 1.- high_p
Numeric. Minimum probability value for which the third color from
colors_pargument will be assigned. Needs to take value between 0 and 1.- colors_p
Vector of valid colors. It should have length 6. The first three colors (default "#EF5D36", "#F39278" and "#F9C8BB") will be assigned to estimated probability values that are lower than the Overall (first higher than the
low_p, then higher than themid_p, lastly higher than thelow_p) and last three for the probability values that are higher than the Overall (with the same order as in the 3 colors option).- statements_list_within
A list of results, processed with
list_client_output_within(). Names of the list elements should indicate the bundle or statement.- statements_list_between
A list of results, processed with
list_client_output_between(). Names of the list elements should indicate the bundle or statement.
Value
The list_render_sheets() is a wrapper over
list_render_sheets_within() and list_render_sheets_between() which
returns openxlsx::Workbook object if the file = NULL. Otherwise it will
save the output to xlsx file, which name is passed to file parameter.
The object/file contains two sheets: "List Experiments Within" and
"List Experiments Between". They contain results of list model, arranged
in a wide format table that allows to compare:
* private, public and the difference between opinions, between the
demographic levels;
* the difference between public and private opinion of each of the
demographic levels.
Examples
library("dplyr")
## Create a data frame with demographic variables
### We select 3 categorical variables as demographic breaks and one artificial
### numeric variable just for the purpose of demonstration.
demo_toy <- list_experiment_toy[1:300, ] %>%
select("response_id", "d_party", "s_gender", "s_region") %>%
mutate(num_var = rnorm(nrow(.), 3, 0.4))
## Create a data frame holding weights
demo_weights <- list_experiment_toy %>%
select("response_id", "weights")
## Tidy the asserted data
### We can run read %>% assert %>% tidy in pipe to make code
### more compact. Tidied data set will be needed by both the list_model()
### and list_statistics_bulk() functions.
list_data_tidy <- list_read_data_bulk(
list_experiment_toy[1:300, ], "response_id"
) %>%
list_assert_data_bulk(demo_toy, id = "response_id", n_items = 4L) %>%
list_tidy_data_bulk("response_id")
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Asserting data for `bundle_1` ────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting Identifiers
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting groups
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting direct question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting response question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting demo variables
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Demo is data.frame with `response_id` column
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ✖ 21 respondents have at least one missing value in break variables - dropping them.
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Asserting data for `bundle_2` ────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting Identifiers
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting groups
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting direct question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting response question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ✖ 4 respondents from control group have response values that should not be available (other than integers from 0 to n_item) - dropping them.
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting demo variables
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Demo is data.frame with `response_id` column
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ✖ 21 respondents have at least one missing value in break variables - dropping them.
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Asserting data for `bundle_3` ────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting Identifiers
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting groups
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting direct question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting response question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Asserting demo variables
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ℹ Demo is data.frame with `response_id` column
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ✖ 21 respondents have at least one missing value in break variables - dropping them.
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
## Run Models
### Pass the tidied data to list_model or list_model_bulk() functions.
if (FALSE) { # \dontrun{
list_model_toy_1 <- list_model(
list_data_tidy[[1]], seed = 666, iter = 200, chains = 1
)
list_model_toy_2 <- list_model(
list_data_tidy[[2]], seed = 666, iter = 200, chains = 1
)
list_model_toy_3 <- list_model(
list_data_tidy[[3]], seed = 666, iter = 200, chains = 1
)
} # }
### After running model you are able to extract the statistics
### The list_model_bulk() function stores the results in models directory.
### To simulate it lets create models directory and save there models mockups.
### The file names needs to end with "bundle_X.rds", where X is the number of
### the bundle.
out_dir <- file.path(tempdir(), "g6tr.list")
if (!dir.exists(out_dir)) dir.create(out_dir, recursive = TRUE)
data("list_model_toy_1")
data("list_model_toy_2")
data("list_model_toy_3")
saveRDS(list_model_toy_1, file.path(out_dir, "list_model_bundle_1.rds"))
saveRDS(list_model_toy_2, file.path(out_dir, "list_model_bundle_2.rds"))
saveRDS(list_model_toy_3, file.path(out_dir, "list_model_bundle_3.rds"))
## The list statistic functions will calculate everything in one shot
### For all the bundles at once:
statistics_output <- list_statistics_bulk(
out_dir, "list_model_", list_data_tidy
)
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Tidying Model Results ────────────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Calculating Overall Model Statistics ─────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating parameters quantiles
#>
✔ Parameters quantiles ready! [11ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public simulated vs. actual answers
#>
✔ Public simulated vs. actual answers ready! [21ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private simulated vs. actual answers
#>
✔ Private simulated vs. actual answers ready! [25ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average public probabilities
#>
✔ Average public probabilities ready! [8ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average private probabilities
#>
✔ Average private probabilities ready! [8ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average delta probabilities
#>
✔ Average delta probabilities ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average survey responses
#>
✔ Average survey responses ready! [11ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Calculating Statistical Tests ────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Calcualting Average group probabilities ──
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public probabilities for: `d_party`
#>
✔ Public probabilities for: `s_gender` ready! [5ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public probabilities for: `s_gender`
#>
✔ Public probabilities for: `s_region` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public probabilities for: `s_region`
#>
✔ Public probabilities for: `d_party` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private probabilities for: `d_party`
#>
✔ Private probabilities for: `s_gender` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private probabilities for: `s_gender`
#>
✔ Private probabilities for: `s_region` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private probabilities for: `s_region`
#>
✔ Private probabilities for: `d_party` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating delta probabilities for: `d_party`
#>
✔ Delta probabilities for: `s_gender` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating delta probabilities for: `s_gender`
#>
✔ Delta probabilities for: `s_region` ready! [11ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating delta probabilities for: `s_region`
#>
✔ Delta probabilities for: `s_region` ready! [22ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Tidying Model Results ────────────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Calculating Overall Model Statistics ─────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating parameters quantiles
#>
✔ Parameters quantiles ready! [11ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public simulated vs. actual answers
#>
✔ Public simulated vs. actual answers ready! [20ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private simulated vs. actual answers
#>
✔ Private simulated vs. actual answers ready! [25ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average public probabilities
#>
✔ Average public probabilities ready! [9ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average private probabilities
#>
✔ Average private probabilities ready! [8ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average delta probabilities
#>
✔ Average delta probabilities ready! [51ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average survey responses
#>
✔ Average survey responses ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Calculating Statistical Tests ────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Calcualting Average group probabilities ──
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public probabilities for: `d_party`
#>
✔ Public probabilities for: `s_gender` ready! [5ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public probabilities for: `s_gender`
#>
✔ Public probabilities for: `s_region` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public probabilities for: `s_region`
#>
✔ Public probabilities for: `d_party` ready! [11ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private probabilities for: `d_party`
#>
✔ Private probabilities for: `s_gender` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private probabilities for: `s_gender`
#>
✔ Private probabilities for: `s_region` ready! [11ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private probabilities for: `s_region`
#>
✔ Private probabilities for: `d_party` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating delta probabilities for: `d_party`
#>
✔ Delta probabilities for: `s_gender` ready! [11ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating delta probabilities for: `s_gender`
#>
✔ Delta probabilities for: `s_region` ready! [11ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating delta probabilities for: `s_region`
#>
✔ Delta probabilities for: `s_region` ready! [23ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Tidying Model Results ────────────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Calculating Overall Model Statistics ─────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating parameters quantiles
#>
✔ Parameters quantiles ready! [11ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public simulated vs. actual answers
#>
✔ Public simulated vs. actual answers ready! [20ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private simulated vs. actual answers
#>
✔ Private simulated vs. actual answers ready! [26ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average public probabilities
#>
✔ Average public probabilities ready! [8ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average private probabilities
#>
✔ Average private probabilities ready! [8ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average delta probabilities
#>
✔ Average delta probabilities ready! [9ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating average survey responses
#>
✔ Average survey responses ready! [9ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Calculating Statistical Tests ────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#> ── Calcualting Average group probabilities ──
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public probabilities for: `d_party`
#>
✔ Public probabilities for: `s_gender` ready! [5ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public probabilities for: `s_gender`
#>
✔ Public probabilities for: `s_region` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating public probabilities for: `s_region`
#>
✔ Public probabilities for: `d_party` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private probabilities for: `d_party`
#>
✔ Private probabilities for: `s_gender` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private probabilities for: `s_gender`
#>
✔ Private probabilities for: `s_region` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating private probabilities for: `s_region`
#>
✔ Private probabilities for: `d_party` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating delta probabilities for: `d_party`
#>
✔ Delta probabilities for: `s_gender` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating delta probabilities for: `s_gender`
#>
✔ Delta probabilities for: `s_region` ready! [10ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
#>
ℹ Calculating delta probabilities for: `s_region`
#>
✔ Delta probabilities for: `s_region` ready! [50ms]
#>
#> Building packages ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 4m
### To get pretty formated xlsx output for both the "within" and "between"
### statistics you can just run:
rendered_sheets <- list_render_sheets(statistics_output)
### Which you can simply save to xlsx file with:
openxlsx::saveWorkbook(
rendered_sheets, file.path(out_dir, "rendered.xlsx"), overwrite = TRUE
)
### You can also specify file argument to which the function will
### automatically save the results. If the file already exists it will be
### overwritten, so be careful.
list_render_sheets(
statistics_output, file = file.path(out_dir, "rendered.xlsx")
)
### Since list_render_sheets() is just a wrapper over functions that make
### "within" and "between" sheets, it is also possible to render just single
### sheet.
### First create outputs using list_client_output_* functions
output_within <- lapply(statistics_output, list_client_output_within)
output_between <- lapply(statistics_output, list_client_output_between)
### Next we can pass the output of list_client_output_within() to
### list_render_sheets_within(). We need to set argument wb_null = TRUE or
### provide an empty Workbook object created with openxlsx package.
render_within <- list_render_sheets_within(output_within, wb = NULL)
### There are some additional parameter that allow you to control the
### probability thresholds that will be colored and the colors itself.
### Lets alter the default probabilities (0.75, 0.92, 0.95) with 0.8, 0.9 and
### 0.96. And also use "pink", "green", "yellow" (for lower than the threshold
### results) and "blue", "violet" and "orange" (for higher than the threshold
### results) instead of default colors:
### "#F9C8BB", "#F39278", "#EF5D36", "#C4E9DA", "#8AD3B4", "#50BD90".
render_between <- list_render_sheets_between(
output_between,
low_p = 0.8, mid_p = 0.90, high_p = 0.96,
colors_p = c("pink", "green", "yellow", "blue", "violet", "orange")
)
### You can save the output to xlsx file in same way as in the example for
### both sheets:
openxlsx::saveWorkbook(
render_between, file.path(out_dir, "between.xlsx"), overwrite = TRUE
)