Skip to contents

Replaces student identifiers with stable sequential pseudonyms and returns a separate key. The key remains identifying and should be stored separately from exported results.

Usage

pseudonymise_results(
  x,
  id_column = "student_id",
  prefix = "student",
  drop_columns = c("student_label", "email"),
  key = NULL
)

Arguments

x

A data frame or a list of data frames, such as the output of tracking_export_data().

id_column

Name of the student identifier column. Defaults to "student_id".

prefix

Prefix used to create pseudonyms. Defaults to "student".

drop_columns

Columns removed from the returned data after pseudonymisation. Defaults to student_label and email.

key

Optional existing key with columns id_column and pseudonym. Use this to keep the same mapping across separate exports.

Value

A list with data, the pseudonymised data in the same shape as x, and key, a tibble mapping original identifiers to pseudonyms.

Examples

results <- data.frame(
  student_id = c("student_001", "student_002"),
  email = c("a@example.org", "b@example.org"),
  score = c(8, 9)
)
pseudonymise_results(results)
#> $data
#>     student_id score
#> 1 student_0001     8
#> 2 student_0002     9
#> 
#> $key
#> # A tibble: 2 × 2
#>   student_id  pseudonym   
#>   <chr>       <chr>       
#> 1 student_001 student_0001
#> 2 student_002 student_0002
#>