tableby
functionControl test and summary settings for the tableby
function.
tableby.control(
test = TRUE,
total = TRUE,
test.pname = NULL,
numeric.simplify = FALSE,
cat.simplify = FALSE,
ordered.simplify = FALSE,
date.simplify = FALSE,
numeric.test = "anova",
cat.test = "chisq",
ordered.test = "trend",
surv.test = "logrank",
date.test = "kwt",
test.always = FALSE,
numeric.stats = c("Nmiss", "meansd", "range"),
cat.stats = c("Nmiss", "countpct"),
ordered.stats = c("Nmiss", "countpct"),
surv.stats = c("Nmiss", "Nevents", "medSurv"),
date.stats = c("Nmiss", "median", "range"),
stats.labels = list(Nmiss = "N-Miss", Nmiss2 = "N-Miss", meansd = "Mean (SD)",
medianrange = "Median (Range)", median = "Median", medianq1q3 = "Median (Q1, Q3)",
q1q3 = "Q1, Q3", iqr = "IQR", mean = "Mean", sd = "SD", var = "Var", max = "Max", min
= "Min", meanCI = "Mean (CI)", sum = "Sum", gmean = "Geom Mean", gsd = "Geom SD",
gmeansd = "Geom Mean (Geom SD)", gmeanCI = "Geom Mean (CI)", range = "Range", Npct =
"N (Pct)", Nevents = "Events", medSurv = "Median Survival", medTime =
"Median Follow-Up", medianmad = "Median (MAD)", overall = "Overall", total =
"Total", difference = "Difference"),
digits = 3L,
digits.count = 0L,
digits.pct = 1L,
digits.p = 3L,
format.p = TRUE,
digits.n = 0L,
conf.level = 0.95,
chisq.correct = FALSE,
simulate.p.value = FALSE,
B = 2000,
times = 1:5,
...
)
logical, telling tableby
whether to perform tests of x variables across levels of the group variable.
logical, telling tableby
whether to calculate a column of totals across group variable.
character string denoting the p-value column name in summary.tableby
.
Modifiable also with modpval.tableby
.
logical, tell tableby
whether to condense numeric/date output to a single line.
NOTE: this only simplifies to one line if there is only one statistic reported, such as meansd
.
In particular, if Nmiss
is specified and there are missings, then the output is not simplified.
logical, tell tableby
whether to remove the first level of the categorical/ordinal variable if binary.
If TRUE
, only the summary stats of the second level are reported (unless there's only one level, in which case it's reported).
NOTE: this only simplifies to one line if there is only one statistic reported, such as countpct
.
In particular, if Nmiss
is specified and there are missings, then the output is not simplified.
name of test for numeric RHS variables in tableby
: anova, kwt (Kruskal-Wallis).
If no LHS variable exists, then a mean is required for a univariate test.
name of test for categorical variables: chisq, fe (Fisher's Exact)
name of test for ordered variables: trend
name of test for survival variables: logrank
name of test for date variables: kwt
Should the test be performed even if one or more by-group has 0 observations? Relevant for kwt and anova.
summary statistics to include for numeric RHS variables within the levels of the group LHS variable. Options are N, Nmiss, Nmiss2, mean, meansd, median, q1q3, medianq1q3, iqr, range, medianrange, or other R built-in or user-written functions.
summary statistics to include for categorical RHS variables within the levels of the group LHS variable. Options are N, Nmiss, Nmiss2, count, countpct, countrowpct, countcellpct, or other R built-in or user-written functions.
summary statistics to include for categorical RHS variables within the levels of the group LHS variable. Options are N, Nmiss, count, countpct, or other R built-in or user-written functions.
summary statistics to include for time-to-event (survival) RHS variables within the levels of the group LHS variable. Options are Nevents, medsurv, NeventsSurv, NriskSurv, medTime, rangeTime.
stats functions to perform for Date variables: Nmiss, median, range, medianrange, q1q3, medianq1q3, or other R built-in or user-written functions.
A named list of labels for all the statistics function names, where the function name is the named element in the list
and the value that goes with it is a string containing the formal name that will be printed in all printed renderings of the output,
e.g., list(countpct="Count (Pct)")
.
Number of decimal places for numeric values.
Number of decimal places for count values.
Number of decimal places for percents.
Number of decimal places for p-values.
Logical, denoting whether to format p-values. See "Details", below.
Number of decimal places for N's in the header. Set it to NA to suppress the N's.
Numeric, denoting what confidence level to use for confidence intervals.
(See, e.g., binomCI
)
logical, correction factor for chisq.test
logical, simulate p-value for categorical tests (fe and chisq)
number of simulations to perform for simulation-based p-value
A vector of times to use for survival summaries.
additional arguments.
A list with settings to be used within the tableby
function.
All tests can be turned off by setting test
to FALSE.
Otherwise, test are set to default settings in this list, or set explicitly in the formula of tableby
.
If format.p
is FALSE
, digits.p
denotes the number of significant digits shown. The
p-values will be in exponential notation if necessary. If format.p
is TRUE
,
digits.p
will determine the number of digits after the decimal point to show. If the p-value
is less than the resulting number of places, it will be formatted to show so.
# NOT RUN {
set.seed(100)
## make 3+ categories for Response
mdat <- data.frame(Response=c(0,0,0,0,0,1,1,1,1,1),
Sex=sample(c("Male", "Female"), 10,replace=TRUE),
Age=round(rnorm(10,mean=40, sd=5)),
HtIn=round(rnorm(10,mean=65,sd=5)))
## allow default summaries in RHS variables, and pass control args to
## main function, to be picked up with ... when calling tableby.control
outResp <- tableby(Response ~ Sex + Age + HtIn, data=mdat, total=FALSE, test=TRUE)
outCtl <- tableby(Response ~ Sex + Age + HtIn, data=mdat,
control=tableby.control(total=TRUE, cat.simplify=TRUE,
cat.stats=c("Nmiss","countpct"),digits=1))
summary(outResp, text=TRUE)
summary(outCtl, text=TRUE)
# }
Run the code above in your browser using DataLab