#' Produce a PDF showing tables of possible de-identification choices, choices that meet a set parameter, and graphs of each decision for individual variables.
#'
#'
#' @inheritParams deidentify_choices_table
#' @inheritParams deidentify_data
#' @param data
#' @param group_rare_values_cols
#' @param preferred_k_score
#' @param file_name
#' A string with the name of the PDF file that will be generated by the function. Must end in '.pdf'. The file will be generated in the current working directory.
#'
#' @return
#' A PDF with a table of all possible choices, a table of the choices that meet the `preferred_k_score` parameter, and graphs of decision outcomes.
#' @export
#'
#' @examples
make_deidentify_choices_report <- function(data,
group_rare_values_cols,
preferred_k_score = NULL,
file_name) {
date_cols <- sapply(data, class)
date_cols <- date_cols[date_cols == "Date"]
if (length(date_cols) > 0) {
date_cols <- names(date_cols)
date_aggregate_list <- list()
for (col in date_cols) {
date_aggregate_list <- list(date_aggregate_list,
graph_aggregate_dates(data[, col]))
}
names(date_aggregate_list) <- paste0("Date column: ", date_cols)
}
rare_value_list <- list()
for (col in group_rare_values_cols) {
rare_value_list <- list(rare_value_list,
graph_group_rare_values(data[, col]))
}
names(rare_value_list) <- paste0("Drop rare values column: ", group_rare_values_cols)
choices_table_all <- deidentify_choices_table(data,
group_rare_values_cols)
if (!is.null(preferred_k_score)) {
choices_table_preferred <- deidentify_choices_table(data,
group_rare_values_cols,
preferred_k_score)
} else {
choices_table_preferred <- NULL
}
rmarkdown::render("inst/deidentify_choices_reported.Rmd",
params = list(
data = data,
set_title = "An evaluation of the effect of de-identification choices on your data",
graphs_list = date_aggregate_list,
rare_value_list = rare_value_list,
choices_table_preferred = choices_table_preferred,
choices_table_all = choices_table_all
),
output_file = file_name)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.