"n={n} | N={N} | p={p} | N_obs={N_obs} | N_miss={N_miss} | N_nonmiss={N_nonmiss} | p_miss={p_miss} | p_nonmiss={p_nonmiss}"
"cv={cv} | N_obs={N_obs} | N_miss={N_miss} | N_nonmiss={N_nonmiss} | p_miss={p_miss} | p_nonmiss={p_nonmiss}"
"{N_miss}, {N_obs}, {N_nonmiss}, {p_miss}, {p_nonmiss}"

dplyr::pull(dplyr::filter(tbl, variable == "response"), stat_0) (`actual`) not equal to "61 (31.606%)" (`expected`).

`actual`:   "61 (31.606)" 
`expected`: "61 (31.606%)"

dplyr::pull(dplyr::filter(tbl, variable == "marker"), stat_0) (`actual`) not equal to "1 (0, 1)" (`expected`).

`actual`:   "1 (0 – 1)"
`expected`: "1 (0, 1)"

tbl[, 1] (`actual`) not equal to c("Chemotherapy Treatment", "Drug A", "Drug B", "Age", "Unknown") (`expected`).

    actual                          | expected                    
[1] "Chemotherapy Treatment, n (%)" - "Chemotherapy Treatment" [1]
[2] "Drug A"                        | "Drug A"                 [2]
[3] "Drug B"                        | "Drug B"                 [3]
[4] "Age, Median (IQR)"             - "Age"                    [4]
[5] "Unknown"                       | "Unknown"                [5]

svy_titanic <- survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq)
df_titanic <- as.data.frame(Titanic) |> tidyr::uncount(weights = Freq)
svy_mtcars <- survey::svydesign(~1, data = mtcars, weights = ~1)
svy_trial <- survey::svydesign(~1, data = trial, weights = ~1)
expect_snapshot(tbl_svysummary(data = svy_titanic) |> as.data.frame())
expect_snapshot(tbl_svysummary(data = svy_mtcars) |> as.data.frame())
expect_snapshot(error = TRUE, tbl_svysummary(data = letters))
expect_snapshot(error = TRUE, tbl_svysummary(data = dplyr::tibble()))
expect_snapshot(tbl_svysummary(data = svy_mtcars, by = am) |> as.data.frame())
expect_snapshot(tbl_svysummary(data = svy_titanic, by = Survived) |> as.data.frame())
expect_snapshot(error = TRUE, tbl_svysummary(svy_mtcars, by = c("mpg", "am")))
tbl_svysummary(svy_trial, include = age, label = list(age = letters))
tbl_svysummary(svy_trial, include = age, label = letters)
response ~ "n={n} | N={N} | p={p} | N_obs={N_obs} | N_miss={N_miss} | N_nonmiss={N_nonmiss} | p_miss={p_miss} | p_nonmiss={p_nonmiss} | p.std.error={p.std.error} | deff={deff} | n_unweighted={n_unweighted} | N_unweighted={N_unweighted} | p_unweighted={p_unweighted}",
"n=61 | N=193 | p=32 | N_obs=200 | N_miss=7 | N_nonmiss=193 | p_miss=3.5 | p_nonmiss=97 | p.std.error=0.0 | deff=Inf | n_unweighted=61 | N_unweighted=193 | p_unweighted=31.6"
# continuous summary when there is no "continuous" stats (just missingness stats)
age ~ "N_obs={N_obs} | N_miss={N_miss} | N_nonmiss={N_nonmiss} | p_miss={p_miss} | p_nonmiss={p_nonmiss}",
"N_obs=200 | N_miss=11 | N_nonmiss=189 | p_miss=5.5 | p_nonmiss=95"
list(age = "mean={mean} | N_obs={N_obs} | N_miss={N_miss} | N_nonmiss={N_nonmiss} | p_miss={p_miss} | p_nonmiss={p_nonmiss}"),
"mean=47 | N_obs=200 | N_miss=11 | N_nonmiss=189 | p_miss=5.5 | p_nonmiss=95"
survey::svydesign(~1, data = _, weights = ~1) |>
tbl <- tbl_svysummary(svy_trial, value = "grade" ~ "III", include = c(grade, response)),
tbl_svysummary(svy_trial, value = "grade" ~ "IV", include = c(grade, response))
tbl_svysummary(svy_trial, include = response, missing_stat = letters)
tbl_svysummary(svy_trial, include = response, missing_stat = 10L)
tbl_svysummary(svy_mtcars, sort = all_categorical() ~ "frequency", include = cyl) |>
tbl_svysummary(svy_mtcars, sort = list(all_categorical() ~ c("frequency", "two")))
tbl_svysummary(svy_mtcars, sort = list(all_categorical() ~ "freq5555uency"))
tbl_svysummary(svy_trial, by = trt, include = grade, percent = "column", statistic = ~"{p}%") |>
tbl_svysummary(svy_trial, by = trt, include = grade, percent = "row", statistic = ~"{p}%") |>
tbl_svysummary(svy_trial, by = trt, include = grade, percent = "cell", statistic = ~"{p}%") |>
tbl_svysummary(svy_trial, by = trt, include = grade, percent = letters, statistic = ~"{p}%")