Skip to contents

Applies privacy rules to objects before they are returned, written, or plotted. By default, masks personally identifiable information in tabular data to privacy-supporting placeholders.

Usage

ensure_privacy(
  x = NULL,
  privacy_level = getOption("engager.privacy_level", "mask"),
  id_columns = c("preferred_name", "name", "first_last", "name_raw", "student_id",
    "email", "transcript_name", "formal_name", "user_name", "speaker"),
  audit_log = TRUE
)

Arguments

x

Data object to apply privacy rules to (typically a tibble)

privacy_level

Privacy level: "mask", "privacy_strict", "privacy_standard", or "none". Deprecated aliases "ferpa_strict" and "ferpa_standard" are accepted with a warning.

id_columns

Vector of column names to treat as identifiers (default: common name columns)

audit_log

Whether to log privacy operations (default: TRUE)

Value

For tabular input, an object with the same data-frame class as x and configured identifier columns transformed according to privacy_level. Non-tabular input is returned unchanged. This is a technical masking result, not a legal or institutional compliance determination.

Details

CRITICAL ETHICAL USE: This function is designed to promote participation equity and educational improvement, NOT surveillance. Outputs are masked by default to support student privacy review; institutional compliance review remains the user's responsibility.

The default behavior is controlled by the global option engager.privacy_level, which is set to "mask" on package load. Pass privacy_level explicitly for one call, or set the engager.privacy_level option for the current R session.

Examples

df <- tibble::tibble(
  section = c("A", "A", "B"),
  preferred_name = c("Alice Johnson", "Bob Lee", "Cara Diaz"),
  session_ct = c(3, 5, 2)
)
ensure_privacy(df)
#> # A tibble: 3 × 3
#>   section preferred_name session_ct
#>   <chr>   <chr>               <dbl>
#> 1 A       Student 01              3
#> 2 A       Student 02              5
#> 3 B       Student 03              2