Actually your problem with deidentifyr
package is not the "@" character, the problem is that it does not accept duplicate ids, if you add the course column to make each row unique, it works.
dataset <- data.frame(Student.ID = c("@11111111", "@11111111", "@11111111", "@2222222", "@3333333"),
Course = c("MAT137", "MAT167", "MAT186", "MAT137", "MAT137"),
Grade = c("A", "C+", "B", "C", "A-"))
library(deidentifyr)
deidentify(dataset, Student.ID, Course)
#> id Grade
#> 1 f9a2c0fa32 A
#> 2 88796051c5 C+
#> 3 9f215474a0 B
#> 4 d17788bf5f C
#> 5 300f0621e9 A-
But the idea here is to make each student identifiable along multiple tables as well, so
I would go with @Chuck advise using anonymizer
package because works with duplicate Ids.
dataset <- data.frame(Student.ID = c("@11111111", "@11111111", "@11111111", "@2222222", "@3333333"),
Course = c("MAT137", "MAT167", "MAT186", "MAT137", "MAT137"),
Grade = c("A", "C+", "B", "C", "A-"))
library(dplyr)
library(anonymizer)
dataset %>%
mutate(Student.ID = anonymize(Student.ID, .algo = "crc32", .seed = 1))
#> Student.ID Course Grade
#> 1 3ac8169d MAT137 A
#> 2 3ac8169d MAT167 C+
#> 3 3ac8169d MAT186 B
#> 4 1c846636 MAT137 C
#> 5 1f97526b MAT137 A-