test_that("Anonymization for factors works", {
set.seed(123)
x <- c(rep("John", 2), rep("Jane", 3), rep("Juliette", 3)) %>% sample %>% as.character
anon_x <- anon_char(x)
anon_x_2 <- anon_char(x, stringAsFactors=FALSE)
expect_true(length(x)==length(anon_x))
expect_equal(unname(sort(table(x))), unname(sort(table(anon_x))))
expect_true(is.factor(anon_x))
expect_false(is.factor(anon_x_2))
expect_true(any(as.character(x)!=as.character(anon_x)))
expect_true(any(x!=anon_x_2))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.