# DEBUG # targets::tar_load(DF_analysis) # params = list( # input_DF = DF_analysis$DF_analysis, # last_scale = "Goodbye_DIRt", # goal = 500, # group_vars = c("DEMOGR_genero_DIRd"), # n_groups = 5 # ) knitr::opts_chunk$set(echo = TRUE) # Check if group_vars columns exist if (all(params$group_vars %in% names(params$input_DF))) { # General data prepatation DF_analysis = params$input_DF %>% select(all_of(params$group_vars), params$last_scale) %>% filter(!is.na(params$last_scale)) %>% count(across(all_of(params$group_vars)), name = "completed") %>% mutate(missing = (params$goal / params$n_groups) - completed, goal = (params$goal / params$n_groups)) # Specific variable transformation # mutate(AIM_DIRt = # case_when( # AIM_DIRt %in% c("d", "e") ~ "EXP", # AIM_DIRt %in% c("c2", "c3") ~ "CONc", # AIM_DIRt %in% c("c1a", "c1b", "ab") ~ "CONa", # TRUE ~ NA_character_)) %>% # rename(group = AIM_DIRt) } else { cli::cli_alert_danger("group_vars NOT in DF_analysis") }
r nrow(params$input_DF)
out of r params$goal
participants completed the experiment (r round(nrow(params$input_DF) / params$goal, 2) * 100
%). The completion criteria is reaching r params$last_scale
.
The final goal (r params$goal
) is divided in r params$n_groups
groups. This is r (params$goal / params$n_groups)
per group.
We create the groups crossing the variables: r paste(params$group_vars, collapse = " & ")
.
if (all(params$group_vars %in% names(DF_analysis))) { DT_analysis = DF_analysis %>% DT::datatable(options = list(dom = 'ti'), rownames = FALSE) DT_analysis %>% DT::formatStyle( columns = c("missing"), target = "cell", color = DT::styleInterval(cuts = c(-10, 0), values = c("red", "orange", "green")) ) } else { cat("group_vars NOT in DF_analysis. Fix in _targets.R") }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.