| ldivvrf | R Documentation |
Checks whether a data.frame satisfies l-diversity: within each
equivalence class defined by the quasi-identifiers, the sensitive
attribute must take at least l distinct values.
A data frame with no rows is refused, as by kanonvrf().
ldivvrf(data, qids, sensitive, l = 3)
data |
data.frame. |
qids |
Character vector of QI column names. |
sensitive |
Name of the sensitive-attribute column. |
l |
Minimum number of distinct sensitive values per class. Default 3. |
Only known (non-NA) sensitive values count towards diversity: a class
whose rows read "HIV", NA, NA tells an adversary the attribute is
HIV or withheld, which is diversity 1. Classes are formed as in
kanonvrf(), with NA in a quasi-identifier as a
level of its own, and sensitive values are compared exactly in the same
way (a factor level that is itself NA is withheld, not a value).
A list with class "morie_l_div" containing:
satisfieslogical.
lthe threshold used.
min_diversityinteger, lowest per-class distinct count.
n_classesinteger.
n_violationsinteger, classes below the threshold.
violating_classesdata.frame of class keys plus their
.diversity count.
summaryhuman-readable.
df <- data.frame(
age = c(25, 25, 25, 25, 32, 32, 32),
sex = c("F", "F", "F", "F", "M", "M", "M"),
dx = c("A", "B", "C", "A", "X", "Y", "Z")
)
# Class {25,F} has 3 distinct dx (A,B,C); {32,M} has 3 (X,Y,Z) -> l=3 holds.
res <- ldivvrf(df, c("age", "sex"), "dx", l = 3)
res$summary
res$satisfies
res$min_diversity
# Demanding l = 4 fails: no class has 4 distinct sensitive values.
bad <- ldivvrf(df, c("age", "sex"), "dx", l = 4)
bad$satisfies
bad$violating_classes
# k-anonymity and l-diversity are complementary: check both.
kanonvrf(df, c("age", "sex"), k = 3)$satisfies
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.