Learn R Programming

arsenal (version 0.5.0)

tableby.control: Control settings for tableby function

Description

Control test and summary settings for the tableby function.

Usage

tableby.control(test = TRUE, total = TRUE, test.pname = NULL,
  cat.simplify = FALSE, numeric.test = "anova", cat.test = "chisq",
  ordered.test = "trend", surv.test = "logrank", date.test = "kwt",
  numeric.stats = c("Nmiss", "meansd", "q1q3", "range"),
  cat.stats = c("Nmiss", "countpct"), ordered.stats = c("Nmiss",
  "countpct"), surv.stats = c("Nevents", "medSurv"), date.stats = c("Nmiss",
  "median", "range"), stats.labels = list(Nmiss = "N-Miss", Nmiss2 = "N-Miss",
  meansd = "Mean (SD)", medianq1q3 = "Median (Q1, Q3)", q1q3 = "Q1, Q3", range =
  "Range", countpct = "Count (Pct)", Nevents = "Events", medsurv =
  "Median Survival"), digits = 3, digits.test = NULL, nsmall = NULL,
  nsmall.pct = NULL, chisq.correct = TRUE, simulate.p.value = FALSE,
  B = 2000, ...)

Arguments

test

logical, telling tableby whether to perform tests of x variables across levels of the group variable.

total

logical, telling tableby whether to calculate a column of totals across group variable.

test.pname

character string denoting the p-value column name in summary.tableby. Modifiable also with modpval.tableby.

cat.simplify

logical, tell tableby whether to include the first level of the categorical variable if binary. If TRUE, only the summary stats of the second level, and total (if TRUE), are calculated. NOTE: this only simplifies to one line if cat.stats is only one statistic, such as countpct. Specifically, if cat.stats includes Nmiss and there are missings, then Nmiss is included in the stats.

numeric.test

set test for numeric RHS variables in tableby to anova or kwt (Kruskal-Wallis) rank-based tests. If no LHS variable exists, then a mean is required for a univariate test.

cat.test

name of test for categorical variables: chisq, fe (Fisher's Exact)

ordered.test

name of test for ordered variables: trend

surv.test

name of test to perform for survival variables: logrank

date.test

name of test to perform for date variables.

numeric.stats

summary statistics to include for numeric RHS variables of tableby within the levels of the group LHS variable. Options are N, Nmiss, mean, meansd, median, q1q3, range, or other R built-in or user-written functions.

cat.stats

summary statistics to include for categorical RHS variables of tableby within the levels of the group LHS variable. Options are N, Nmiss, count, countpct, or other R built-in or user-written functions.

ordered.stats

summary statistics to include for categorical RHS variables of tableby within the levels of the group LHS variable. Options are N, Nmiss, count, countpct, or other R built-in or user-written functions.

surv.stats

summary statistics to include for time-to-event (survival) RHS variables of tableby within the levels of the group LHS variable. Options are Nevents, medsurv.

date.stats

stats functions to perform for Date variables

stats.labels

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)").

digits

digits to print for non-integer statistics

digits.test

digits to print for test statistic p-values

nsmall

digits to print after decimal point for numerics

nsmall.pct

digits to print after decimal point for percentages

chisq.correct

logical, correction factor for chisq.test

simulate.p.value

logical, simulate p-value for categorical tests (fe and chisq)

B

number of simulations to perform for simulation-based p-value

...

additional arguments to be passed to internal tableby functions and kept for summary method options, such as digits.

Value

A list with settings to be used within the tableby function.

Details

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.

See Also

anova, chisq.test, tableby, summary.tableby

Examples

Run this code
# 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