Nothing
test_that(desc = "centrality description works as expected - no missing data", code = {
set.seed(123)
df <- purrr::pmap_dfr(
.l = list(
data = list(mtcars),
x = alist(am),
y = alist(wt),
type = list("p", "np", "r", "b"),
digits = 3L,
conf.level = list(0.89, 0.99, 0.90, 0.50)
),
.f = centrality_description
)
expect_snapshot(select(df, -expression))
expect_snapshot(df[["expression"]])
})
test_that(desc = "centrality description works as expected - missing data", code = {
# some MAP estimates are different on macOS compared to windows and linux
skip_on_os(c("windows", "linux"))
set.seed(123)
df_na <- purrr::pmap_dfr(
.l = list(
data = list(bugs_long),
x = alist(gender),
y = alist(desire),
type = list("p", "np", "r", "b"),
digits = 3L,
conf.level = list(0.89, 0.99, 0.90, 0.50)
),
.f = centrality_description
)
expect_snapshot(select(df_na, -expression))
expect_snapshot(df_na[["expression"]])
})
test_that(desc = "centrality description works when variable is named `variable`", code = {
df_var <- dplyr::rename(mtcars, variable = cyl)
set.seed(123)
res <- suppressWarnings(centrality_description(df_var, variable, wt))
expect_snapshot(select(res, -expression))
expect_snapshot(res[["expression"]])
})
test_that("centrality description works with reserved response names", {
base_data <- data.frame(group = rep(c("a", "b"), each = 3L), value = 1:6)
for (response in c("n", "Mean", "SD", "IQR")) {
data <- rlang::set_names(base_data, c("group", response))
result <- centrality_description(data, group, !!rlang::sym(response))
expect_identical(names(result)[1:2], c("group", response))
expect_identical(result[[response]], c(2, 5))
}
})
test_that("centrality description works with reserved grouping names", {
base_data <- data.frame(group = rep(c("a", "b"), each = 3L), value = 1:6)
expected <- centrality_description(base_data, group, value)
# `centrality` and `digits` are also local variables of the function
for (group in c("n", "Mean", "SD", "IQR", "centrality", "digits")) {
data <- rlang::set_names(base_data, c(group, "value"))
result <- centrality_description(data, !!rlang::sym(group), value)
expect_identical(names(result)[1:2], c(group, "value"))
expect_identical(result[["value"]], c(2, 5))
expect_identical(result[["expression"]], expected[["expression"]])
}
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.