### Install srvyr Source: https://gdfe.co/srvyr Installation commands for the srvyr package from CRAN or GitHub. ```R install.packages("srvyr") # or for development version # remotes::install_github("gergness/srvyr") ``` -------------------------------- ### Initialize Survey Design Source: https://gdfe.co/srvyr Define survey structure using as_survey_design with bare column names. ```R library(srvyr, warn.conflicts = FALSE) data(api, package = "survey") dstrata <- apistrat %>% as_survey_design(strata = stype, weights = pw) ``` -------------------------------- ### Use survey Package Functions Source: https://gdfe.co/srvyr Directly apply functions from the survey package to srvyr objects. ```R my_model <- survey::svyglm(api99 ~ stype, dstrata) summary(my_model) ``` -------------------------------- ### Grouped Summaries Source: https://gdfe.co/srvyr Calculate summary statistics by groups using group_by and summarise. ```R dstrata %>% group_by(stype) %>% summarise(api_diff = survey_mean(api_diff, vartype = "ci")) ``` -------------------------------- ### Summarize Survey Data Source: https://gdfe.co/srvyr Calculate summary statistics like mean, total, or quantile using summarise. ```R dstrata %>% summarise(api_diff = survey_mean(api_diff, vartype = "ci")) ``` -------------------------------- ### Mutate Survey Data Source: https://gdfe.co/srvyr Modify or add variables to the survey design object using mutate. ```R dstrata <- dstrata %>% mutate(api_diff = api00 - api99) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.