diff --git a/R/svycox.R b/R/svycox.R index 23a0942..6c93884 100644 --- a/R/svycox.R +++ b/R/svycox.R @@ -15,9 +15,11 @@ #' #' if (is.null(pbc$albumin)) pbc$albumin <- pbc$alb ## pre2.9.0 #' -#' dpbc <- survey::svydesign(id = ~1, prob = ~randprob, strata = ~edema, data = subset(pbc, randomized)) +#' dpbc <- survey::svydesign(id = ~1, prob = ~randprob, strata = ~edema, +#' data = subset(pbc, randomized)) #' -#' model <- survey::svycoxph(Surv(time, status > 0) ~ sex + protime + albumin + stage, design = dpbc) +#' model <- survey::svycoxph(Surv(time, status > 0) ~ sex + protime + albumin + stage, +#' design = dpbc) #' svycox.display(model) #' @seealso #' \code{\link[survey]{svycoxph}} diff --git a/man/CreateTableOne2.Rd b/man/CreateTableOne2.Rd index 17e6c25..25c700c 100644 --- a/man/CreateTableOne2.Rd +++ b/man/CreateTableOne2.Rd @@ -99,6 +99,6 @@ Combine CreateTableOne & print function in tableone package DETAILS } \examples{ - library(survival) - CreateTableOne2(vars = names(lung), strata = "sex", data = lung) +library(survival) +CreateTableOne2(vars = names(lung), strata = "sex", data = lung) } diff --git a/man/CreateTableOneJS.Rd b/man/CreateTableOneJS.Rd index 05d2baa..f20876f 100644 --- a/man/CreateTableOneJS.Rd +++ b/man/CreateTableOneJS.Rd @@ -105,6 +105,6 @@ Combine CreateTableOne & print function in tableone package DETAILS } \examples{ - library(survival) - CreateTableOneJS(vars = names(lung), strata = "sex", data = lung) +library(survival) +CreateTableOneJS(vars = names(lung), strata = "sex", data = lung) } diff --git a/man/TableSubgroupCox.Rd b/man/TableSubgroupCox.Rd index db4d097..1824042 100644 --- a/man/TableSubgroupCox.Rd +++ b/man/TableSubgroupCox.Rd @@ -42,21 +42,28 @@ Sub-group analysis table for Cox/svycox model. This result is used to make forestplot. } \examples{ -library(survival);library(dplyr) -lung \%>\% - mutate(status = as.integer(status == 1), - sex = factor(sex), - kk = factor(as.integer(pat.karno >= 70))) -> lung +library(survival) +library(dplyr) +lung \%>\% + mutate( + status = as.integer(status == 1), + sex = factor(sex), + kk = factor(as.integer(pat.karno >= 70)) + ) -> lung TableSubgroupCox(Surv(time, status) ~ sex, data = lung, time_eventrate = 100) -TableSubgroupCox(Surv(time, status) ~ sex, var_subgroup = "kk", data = lung, - time_eventrate = 100) +TableSubgroupCox(Surv(time, status) ~ sex, + var_subgroup = "kk", data = lung, + time_eventrate = 100 +) ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) TableSubgroupCox(Surv(time, status) ~ sex, data = data.design, time_eventrate = 100) -TableSubgroupCox(Surv(time, status) ~ sex, var_subgroup = "kk", data = data.design, - time_eventrate = 100) +TableSubgroupCox(Surv(time, status) ~ sex, + var_subgroup = "kk", data = data.design, + time_eventrate = 100 +) } \seealso{ \code{\link[purrr]{safely}},\code{\link[purrr]{map}},\code{\link[purrr]{map2}} diff --git a/man/TableSubgroupGLM.Rd b/man/TableSubgroupGLM.Rd index b424a3f..191ccfb 100644 --- a/man/TableSubgroupGLM.Rd +++ b/man/TableSubgroupGLM.Rd @@ -42,11 +42,14 @@ Sub-group analysis table for GLM. This result is used to make forestplot. } \examples{ -library(survival);library(dplyr) -lung \%>\% - mutate(status = as.integer(status == 1), - sex = factor(sex), - kk = factor(as.integer(pat.karno >= 70))) -> lung +library(survival) +library(dplyr) +lung \%>\% + mutate( + status = as.integer(status == 1), + sex = factor(sex), + kk = factor(as.integer(pat.karno >= 70)) + ) -> lung TableSubgroupGLM(status ~ sex, data = lung, family = "binomial") TableSubgroupGLM(status ~ sex, var_subgroup = "kk", data = lung, family = "binomial") diff --git a/man/TableSubgroupMultiCox.Rd b/man/TableSubgroupMultiCox.Rd index c7f1671..db630c5 100644 --- a/man/TableSubgroupMultiCox.Rd +++ b/man/TableSubgroupMultiCox.Rd @@ -45,20 +45,27 @@ Multiple sub-group analysis table for Cox/svycox model. This result is used to make forestplot. } \examples{ -library(survival);library(dplyr) -lung \%>\% - mutate(status = as.integer(status == 1), - sex = factor(sex), - kk = factor(as.integer(pat.karno >= 70)), - kk1 = factor(as.integer(pat.karno >= 60))) -> lung -TableSubgroupMultiCox(Surv(time, status) ~ sex, var_subgroups = c("kk", "kk1"), - data=lung, time_eventrate = 100, line = TRUE) +library(survival) +library(dplyr) +lung \%>\% + mutate( + status = as.integer(status == 1), + sex = factor(sex), + kk = factor(as.integer(pat.karno >= 70)), + kk1 = factor(as.integer(pat.karno >= 60)) + ) -> lung +TableSubgroupMultiCox(Surv(time, status) ~ sex, + var_subgroups = c("kk", "kk1"), + data = lung, time_eventrate = 100, line = TRUE +) ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) -TableSubgroupMultiCox(Surv(time, status) ~ sex, var_subgroups = c("kk", "kk1"), - data = data.design, time_eventrate = 100) +TableSubgroupMultiCox(Surv(time, status) ~ sex, + var_subgroups = c("kk", "kk1"), + data = data.design, time_eventrate = 100 +) } \seealso{ \code{\link[purrr]{map}} diff --git a/man/TableSubgroupMultiGLM.Rd b/man/TableSubgroupMultiGLM.Rd index 140ec8a..0e324fd 100644 --- a/man/TableSubgroupMultiGLM.Rd +++ b/man/TableSubgroupMultiGLM.Rd @@ -45,20 +45,27 @@ Multiple sub-group analysis table for GLM. This result is used to make forestplot. } \examples{ -library(survival);library(dplyr) -lung \%>\% - mutate(status = as.integer(status == 1), - sex = factor(sex), - kk = factor(as.integer(pat.karno >= 70)), - kk1 = factor(as.integer(pat.karno >= 60))) -> lung -TableSubgroupMultiGLM(status ~ sex, var_subgroups = c("kk", "kk1"), - data=lung, line = TRUE, family = "binomial") +library(survival) +library(dplyr) +lung \%>\% + mutate( + status = as.integer(status == 1), + sex = factor(sex), + kk = factor(as.integer(pat.karno >= 70)), + kk1 = factor(as.integer(pat.karno >= 60)) + ) -> lung +TableSubgroupMultiGLM(status ~ sex, + var_subgroups = c("kk", "kk1"), + data = lung, line = TRUE, family = "binomial" +) ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) -TableSubgroupMultiGLM(status ~ sex, var_subgroups = c("kk", "kk1"), - data = data.design, family = "binomial") +TableSubgroupMultiGLM(status ~ sex, + var_subgroups = c("kk", "kk1"), + data = data.design, family = "binomial" +) } \seealso{ \code{\link[purrr]{map}} diff --git a/man/coefNA.Rd b/man/coefNA.Rd index 8b64932..8fc7ae9 100644 --- a/man/coefNA.Rd +++ b/man/coefNA.Rd @@ -19,5 +19,5 @@ Make coefficient table with NA DETAILS } \examples{ - coefNA(glm(mpg ~ wt + qsec, data = mtcars)) +coefNA(glm(mpg ~ wt + qsec, data = mtcars)) } diff --git a/man/cox2.display.Rd b/man/cox2.display.Rd index 20d07fe..11eb997 100644 --- a/man/cox2.display.Rd +++ b/man/cox2.display.Rd @@ -21,9 +21,10 @@ Table for coxph.object with model option: TRUE - allow "frailty" or "cluster" mo GEE like - cluster, Mixed effect model like - frailty } \examples{ - library(survival);data(lung) - fit1 <- coxph(Surv(time, status) ~ ph.ecog + age + cluster(inst), data = lung, model = TRUE) - fit2 <- coxph(Surv(time, status) ~ ph.ecog + age + frailty(inst), data = lung, model = TRUE) - cox2.display(fit1) - cox2.display(fit2) +library(survival) +data(lung) +fit1 <- coxph(Surv(time, status) ~ ph.ecog + age + cluster(inst), data = lung, model = TRUE) +fit2 <- coxph(Surv(time, status) ~ ph.ecog + age + frailty(inst), data = lung, model = TRUE) +cox2.display(fit1) +cox2.display(fit2) } diff --git a/man/coxExp.Rd b/man/coxExp.Rd index 83f01e1..92a0135 100644 --- a/man/coxExp.Rd +++ b/man/coxExp.Rd @@ -21,7 +21,7 @@ Transform the unit of coefficients to "HR" DETAILS } \examples{ - library(coxme) - fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1|inst), lung) - jstable:::coxExp(jstable:::coxmeTable(fit)) +library(coxme) +fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) +jstable:::coxExp(jstable:::coxmeTable(fit)) } diff --git a/man/coxme.display.Rd b/man/coxme.display.Rd index d82b1d5..06e7a3c 100644 --- a/man/coxme.display.Rd +++ b/man/coxme.display.Rd @@ -21,7 +21,7 @@ Make mixed effect model results from coxme.object (coxme package) DETAILS } \examples{ - library(coxme) - fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1|inst), lung) - coxme.display(fit) +library(coxme) +fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) +coxme.display(fit) } diff --git a/man/coxmeTable.Rd b/man/coxmeTable.Rd index 7ebda95..0015e9f 100644 --- a/man/coxmeTable.Rd +++ b/man/coxmeTable.Rd @@ -19,7 +19,7 @@ Extract fixed effect table in coxme.object DETAILS } \examples{ - library(coxme) - fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1|inst), lung) - jstable:::coxmeTable(fit) +library(coxme) +fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) +jstable:::coxmeTable(fit) } diff --git a/man/extractAIC.coxme.Rd b/man/extractAIC.coxme.Rd index 8691613..3a24b43 100644 --- a/man/extractAIC.coxme.Rd +++ b/man/extractAIC.coxme.Rd @@ -25,7 +25,7 @@ Extract AIC from coxme.object DETAILS } \examples{ - library(coxme) - fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1|inst), lung) - extractAIC(fit) +library(coxme) +fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) +extractAIC(fit) } diff --git a/man/geeExp.Rd b/man/geeExp.Rd index 633b5ae..ba7e856 100644 --- a/man/geeExp.Rd +++ b/man/geeExp.Rd @@ -23,10 +23,12 @@ Transform the unit of coefficients to "Coeff", "OR" or "RR" DETAILS } \examples{ - library(geepack) - data(dietox) - dietox$Cu <- as.factor(dietox$Cu) - gee.uni <- geeUni("Weight", c("Time", "Cu"), data = dietox, id.vec = dietox$Pig, - family = "gaussian", cor.type = "exchangeable") - gee.exp <- geeExp(gee.uni, "binomial", 2) +library(geepack) +data(dietox) +dietox$Cu <- as.factor(dietox$Cu) +gee.uni <- geeUni("Weight", c("Time", "Cu"), + data = dietox, id.vec = dietox$Pig, + family = "gaussian", cor.type = "exchangeable" +) +gee.exp <- geeExp(gee.uni, "binomial", 2) } diff --git a/man/geeUni.Rd b/man/geeUni.Rd index c17489d..3ad82c6 100644 --- a/man/geeUni.Rd +++ b/man/geeUni.Rd @@ -29,9 +29,11 @@ Extract the coefficients of univariate gee using geeglm function (geepack packag DETAILS } \examples{ - library(geepack) - data(dietox) - dietox$Cu <- as.factor(dietox$Cu) - gee.uni <- geeUni("Weight", "Time", data = dietox, id.vec = dietox$Pig, - family = "gaussian", cor.type = "exchangeable") +library(geepack) +data(dietox) +dietox$Cu <- as.factor(dietox$Cu) +gee.uni <- geeUni("Weight", "Time", + data = dietox, id.vec = dietox$Pig, + family = "gaussian", cor.type = "exchangeable" +) } diff --git a/man/geeglm.display.Rd b/man/geeglm.display.Rd index 82ac86f..7a6459f 100644 --- a/man/geeglm.display.Rd +++ b/man/geeglm.display.Rd @@ -21,12 +21,14 @@ Make gee results from "geeglm" object DETAILS } \examples{ - library(geepack) - data(dietox) - dietox$Cu <- as.factor(dietox$Cu) - gee01 <- geeglm (Weight ~ Time + Cu , id =Pig, data = dietox, - family=gaussian,corstr="ex") - geeglm.display(gee01) +library(geepack) +data(dietox) +dietox$Cu <- as.factor(dietox$Cu) +gee01 <- geeglm(Weight ~ Time + Cu, + id = Pig, data = dietox, + family = gaussian, corstr = "ex" +) +geeglm.display(gee01) } \seealso{ \code{\link[data.table]{data.table-package}} diff --git a/man/glmshow.display.Rd b/man/glmshow.display.Rd index f7b10ee..589df9a 100644 --- a/man/glmshow.display.Rd +++ b/man/glmshow.display.Rd @@ -21,7 +21,7 @@ Show summary table of glm object(regression, logistic). DETAILS } \examples{ - glmshow.display(glm(mpg ~ wt + qsec, data = mtcars)) +glmshow.display(glm(mpg ~ wt + qsec, data = mtcars)) } \seealso{ \code{\link[stats]{glm}} diff --git a/man/lmer.display.Rd b/man/lmer.display.Rd index bec1a3a..c7a6132 100644 --- a/man/lmer.display.Rd +++ b/man/lmer.display.Rd @@ -23,9 +23,9 @@ Make mixed effect model results from "lmerMod" or "glmerMod" object (lme4 packag DETAILS } \examples{ - library(geepack) - data(dietox) - dietox$Cu <- as.factor(dietox$Cu) - l1 <- lme4::lmer(Weight ~ Time + Cu + (1|Pig) + (1|Evit), data = dietox) - lmer.display(l1) +library(geepack) +data(dietox) +dietox$Cu <- as.factor(dietox$Cu) +l1 <- lme4::lmer(Weight ~ Time + Cu + (1 | Pig) + (1 | Evit), data = dietox) +lmer.display(l1) } diff --git a/man/lmerExp.Rd b/man/lmerExp.Rd index 3df7440..c53df80 100644 --- a/man/lmerExp.Rd +++ b/man/lmerExp.Rd @@ -23,5 +23,5 @@ Transform the unit of coefficients to "Coeff", "OR" or "RR" DETAILS } \examples{ - #EXAMPLE1 +# EXAMPLE1 } diff --git a/man/opt.roc.Rd b/man/opt.roc.Rd index 13678f4..7ae1ddb 100644 --- a/man/opt.roc.Rd +++ b/man/opt.roc.Rd @@ -19,5 +19,5 @@ DT::datatable option for ROC result DETAILS } \examples{ - options = opt.roc("mtcars") +options <- opt.roc("mtcars") } diff --git a/man/opt.simpledown.Rd b/man/opt.simpledown.Rd index 85205a9..ba8ad14 100644 --- a/man/opt.simpledown.Rd +++ b/man/opt.simpledown.Rd @@ -19,5 +19,5 @@ Simple download DT::datatable option - No filter, No page DETAILS } \examples{ - options = opt.simpledown("mtcars") +options <- opt.simpledown("mtcars") } diff --git a/man/opt.tb1.Rd b/man/opt.tb1.Rd index 4e36539..7ab0a63 100644 --- a/man/opt.tb1.Rd +++ b/man/opt.tb1.Rd @@ -19,5 +19,5 @@ DT::datatable option for table 1 DETAILS } \examples{ - options = opt.tb1("mtcars") +options <- opt.tb1("mtcars") } diff --git a/man/opt.tbreg.Rd b/man/opt.tbreg.Rd index c964d46..1ac74ed 100644 --- a/man/opt.tbreg.Rd +++ b/man/opt.tbreg.Rd @@ -19,5 +19,5 @@ DT::datatable option for glm, gee(geepack package), lmer/glmer(lme4 package) DETAILS } \examples{ - options = opt.tbreg("mtcars") +options <- opt.tbreg("mtcars") } diff --git a/man/svyCreateTableOne2.Rd b/man/svyCreateTableOne2.Rd index 97eb611..94c6310 100644 --- a/man/svyCreateTableOne2.Rd +++ b/man/svyCreateTableOne2.Rd @@ -72,11 +72,16 @@ Combine svyCreateTableOne & print function in tableone package DETAILS } \examples{ - library(survey);data(nhanes) - nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU) - nhanesSvy <- svydesign(ids = ~ SDMVPSU, strata = ~ SDMVSTRA, weights = ~ WTMEC2YR, - nest = TRUE, data = nhanes) - svyCreateTableOne2(vars = c("HI_CHOL","race","agecat","RIAGENDR"), - strata = "RIAGENDR", data = nhanesSvy, - factorVars = c("HI_CHOL", "race", "RIAGENDR")) +library(survey) +data(nhanes) +nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU) +nhanesSvy <- svydesign( + ids = ~SDMVPSU, strata = ~SDMVSTRA, weights = ~WTMEC2YR, + nest = TRUE, data = nhanes +) +svyCreateTableOne2( + vars = c("HI_CHOL", "race", "agecat", "RIAGENDR"), + strata = "RIAGENDR", data = nhanesSvy, + factorVars = c("HI_CHOL", "race", "RIAGENDR") +) } diff --git a/man/svyCreateTableOneJS.Rd b/man/svyCreateTableOneJS.Rd index 9e8b590..cc3c0cf 100644 --- a/man/svyCreateTableOneJS.Rd +++ b/man/svyCreateTableOneJS.Rd @@ -78,11 +78,16 @@ Combine svyCreateTableOne & print function in tableone package DETAILS } \examples{ - library(survey);data(nhanes) - nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU) - nhanesSvy <- svydesign(ids = ~ SDMVPSU, strata = ~ SDMVSTRA, weights = ~ WTMEC2YR, - nest = TRUE, data = nhanes) - svyCreateTableOneJS(vars = c("HI_CHOL","race","agecat","RIAGENDR"), - strata = "RIAGENDR", data = nhanesSvy, - factorVars = c("HI_CHOL", "race", "RIAGENDR")) +library(survey) +data(nhanes) +nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU) +nhanesSvy <- svydesign( + ids = ~SDMVPSU, strata = ~SDMVSTRA, weights = ~WTMEC2YR, + nest = TRUE, data = nhanes +) +svyCreateTableOneJS( + vars = c("HI_CHOL", "race", "agecat", "RIAGENDR"), + strata = "RIAGENDR", data = nhanesSvy, + factorVars = c("HI_CHOL", "race", "RIAGENDR") +) } diff --git a/man/svycox.display.Rd b/man/svycox.display.Rd index 3246adb..35144c0 100644 --- a/man/svycox.display.Rd +++ b/man/svycox.display.Rd @@ -21,19 +21,22 @@ Table for complex design cox model. DETAILS } \examples{ - library(survival);data(pbc) - pbc$sex = factor(pbc$sex) - pbc$stage = factor(pbc$stage) - pbc$randomized<-with(pbc, !is.na(trt) & trt>0) - biasmodel<-glm(randomized~age*edema,data=pbc,family=binomial) - pbc$randprob<-fitted(biasmodel) - - if (is.null(pbc$albumin)) pbc$albumin<-pbc$alb ##pre2.9.0 - - dpbc <- survey::svydesign(id=~1, prob=~randprob, strata=~edema, data=subset(pbc,randomized)) - - model <- survey::svycoxph(Surv(time,status>0)~ sex + protime + albumin + stage,design=dpbc) - svycox.display(model) +library(survival) +data(pbc) +pbc$sex <- factor(pbc$sex) +pbc$stage <- factor(pbc$stage) +pbc$randomized <- with(pbc, !is.na(trt) & trt > 0) +biasmodel <- glm(randomized ~ age * edema, data = pbc, family = binomial) +pbc$randprob <- fitted(biasmodel) + +if (is.null(pbc$albumin)) pbc$albumin <- pbc$alb ## pre2.9.0 + +dpbc <- survey::svydesign(id = ~1, prob = ~randprob, strata = ~edema, + data = subset(pbc, randomized)) + +model <- survey::svycoxph(Surv(time, status > 0) ~ sex + protime + albumin + stage, + design = dpbc) +svycox.display(model) } \seealso{ \code{\link[survey]{svycoxph}} diff --git a/man/svyglm.display.Rd b/man/svyglm.display.Rd index dce679b..873dcc2 100644 --- a/man/svyglm.display.Rd +++ b/man/svyglm.display.Rd @@ -21,11 +21,12 @@ table for svyglm.object (survey package). DETAILS } \examples{ - library(survey);data(api) - apistrat$tt = c(rep(1, 20), rep(0, nrow(apistrat) -20)) - dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc) - ds <- svyglm(api00~ell+meals+cname+mobility, design=dstrat) - ds2 <- svyglm(tt~ell+meals+cname+mobility, design=dstrat, family = quasibinomial()) - svyregress.display(ds) - svyregress.display(ds2) +library(survey) +data(api) +apistrat$tt <- c(rep(1, 20), rep(0, nrow(apistrat) - 20)) +dstrat <- svydesign(id = ~1, strata = ~stype, weights = ~pw, data = apistrat, fpc = ~fpc) +ds <- svyglm(api00 ~ ell + meals + cname + mobility, design = dstrat) +ds2 <- svyglm(tt ~ ell + meals + cname + mobility, design = dstrat, family = quasibinomial()) +svyregress.display(ds) +svyregress.display(ds2) }