## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>", warning = FALSE, message = FALSE) library(mudnester) ## ----detect-demo-------------------------------------------------------------- patient_data <- data.frame( patient_name = c("John Doe", "Jane Smith"), dob = as.Date(c("1980-01-01", "1975-05-15")), mrn = c("12345", "67890"), age5cat = factor(c("18-64", "18-64")), # preserved automatically diagnosis = c("Condition A", "Condition B"), lab_value = c(120, 95) ) result <- suppressMessages(molting(patient_data)) names(result$deidentified) # hash + retained columns names(result$lookup) # hash + removed columns ## ----output-structure--------------------------------------------------------- str(result, max.level = 1) head(result$lookup) ## ----hash-algos, eval=FALSE--------------------------------------------------- # # SHA-256 (default, recommended) # result_256 <- molting(patient_data, hash_method = "sha256") # # # MD5 (shorter hash, faster, lower collision resistance) # result_md5 <- molting(patient_data, hash_method = "md5") # # # Blake3 (fast and cryptographically strong — good for large datasets) # result_b3 <- molting(patient_data, hash_method = "blake3") ## ----id-cols------------------------------------------------------------------ # Hash only on MRN and DOB — more stable if name variations exist result_ids <- suppressMessages( molting(patient_data, id_cols = c("mrn", "dob")) ) result_ids$lookup ## ----additional--------------------------------------------------------------- patient_data2 <- patient_data patient_data2$study_code <- c("SC-001","SC-002") result2 <- suppressMessages( molting(patient_data2, additional_pii_cols = "study_code") ) names(result2$deidentified) ## ----no-lookup---------------------------------------------------------------- deidentified_only <- suppressMessages( molting(patient_data, return_lookup = FALSE) ) class(deidentified_only) # a data frame, not a list