test_that("as_tibble checks an attr to avoid decay to tibble", {
edf <- cases_deaths_subset
expect_identical(class(as_tibble(edf)), c("tbl_df", "tbl", "data.frame"))
attr(edf, "decay_to_tibble") <- TRUE
expect_identical(class(as_tibble(edf)), c("tbl_df", "tbl", "data.frame"))
attr(edf, "decay_to_tibble") <- FALSE
expect_identical(class(as_tibble(edf)), c("epi_df", "tbl_df", "tbl", "data.frame"))
})
test_that("as_tibble ungroups if needed", {
edf <- cases_deaths_subset %>% group_by(geo_value)
# removes the grouped_df class
expect_identical(class(as_tibble(edf)), c("tbl_df", "tbl", "data.frame"))
attr(edf, "decay_to_tibble") <- TRUE
expect_identical(class(as_tibble(edf)), c("tbl_df", "tbl", "data.frame"))
attr(edf, "decay_to_tibble") <- FALSE
# removes grouped_df but not `epi_df`
expect_identical(class(as_tibble(edf)), c("epi_df", "tbl_df", "tbl", "data.frame"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.