context("test-separate_n")
ds_in <-
tibble::tibble(
x = c("a,b,c", "a,b", "a,b,a,c", "A")
)
ds_out <-
tibble::tibble(
new_var_1 = c("a", "a", "a", "A"),
new_var_2 = c("b", "b", "b", NA),
new_var_3 = c("c", NA, "a", NA),
new_var_4 = c(NA, NA, "c", NA)
)
test_that("seperate_n creates correct number of new variables", {
expect_equal(
separate_n(ds_in, x, sep = ","),
ds_out
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.