library(tidyverse)
library(gtsummary)
library(survey)
library(srvyr)
penguins <- palmerpenguins::penguins %>% tidyr::drop_na()
t1 <- penguins %>% gtsummary::tbl_summary()
t2 <- penguins %>%
mutate(
Weight = runif(333, 1, 10) * 592693,
VarUnit = sample(1:3, size = 333, replace = TRUE),
Stratum = sample(1:5, size = 333, replace = TRUE)
) %>%
srvyr::as_survey_design(
weights = Weight,
strata = Stratum,
ids = VarUnit,
nest = TRUE
) %>%
gtsummary::tbl_svysummary(
include = c(everything(), -Weight, -VarUnit, -Stratum)
)
tbl_merge(list(t2, t1)) # work
tbl_merge(list(t1, t2)) # does not work
I don't know why, can you give me some advice and help?
Thanks