我对调查数据和 gtsumarry 包还很陌生。
我尝试使用以下代码从调查数据创建分层表,但收到错误“错误:问题mutate()
input tbl
".
# Reading the subset of the data
fileUrl <- "https://raw.github.com/Shadi-Sadie/Paper-1-Cancer-Screening-and-Immigrants/master/Cleaned%20Data/subset.csv"
SData<-read.csv( fileUrl , header = TRUE, sep ="," )
# Setting the weight
options( "survey.replicates.mse" = TRUE)
svy <- svrepdesign(repweights = "PWGTP[0-9]+",
weights = ~PWGTP,
combined.weights = TRUE,
type = "JK1",
scale = 4/80, rscales = rep(1, 80),
data = SData)
# creating the table
SData %>%
select(CITG, HICOV, ESRG , EXPANSION) %>%
tbl_strata(
strata = CITG,
.tbl_fun =
~ .x %>% tbl_svysummary(
by = EXPANSION,
include = c(CITG, HICOV, ESRG , EXPANSION),
label = list(CITG ~ "Nativity",
HICOV~ "Any health insurance",
ESRG~ "Employment",
EXPANSION ~ "Expansion" )
)
)
如果可以使用的话tbl_svysummary()
与tbl_strata()
谁能告诉我我哪里做错了?