context("test-count_all")
ds_mt <-
mtcars %>%
dplyr::transmute(
am = factor(am, labels = c("auto", "manual")),
vs = factor(vs, labels = c("V", "S")) %>% as.character()
)
# Generates code for expected output
# count_all(ds_mt) %>% dput()
expected_output <-
structure(
list(
am =
structure(
list(x = structure(1:2, .Label = c("auto", "manual"), class = "factor"),
n = c(19L, 13L)), class = c("tbl_df", "tbl", "data.frame"),
.Names = c("x", "n"), row.names = c(NA, -2L)
),
vs =
structure(
list(x = structure(1:2, .Label = c("S", "V"), class = "factor"),
n = c(14L, 18L)), class = c("tbl_df", "tbl", "data.frame"),
.Names = c("x", "n"), row.names = c(NA, -2L))
),
.Names = c("am", "vs")
)
test_that("count_all() creates a list of tibbles", {
expect_equal(expected_output, count_all(ds_mt))
})
test_that("count_all() creates expected number of dataframes", {
expect_equal(length(count_all(ds_mt)), 2)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.