rm_covsum_nested {BiostatsUHNplus}R Documentation

Outputs a nested version of reportRmd::rm_covsum()

Description

Outputs a nested version of reportRmd::rm_covsum()

Usage

rm_covsum_nested(
  data,
  covs,
  maincov = NULL,
  id = NULL,
  caption = NULL,
  tableOnly = FALSE,
  covTitle = "",
  digits = 1,
  digits.cat = 0,
  nicenames = TRUE,
  IQR = FALSE,
  all.stats = FALSE,
  pvalue = TRUE,
  effSize = TRUE,
  p.adjust = "none",
  unformattedp = FALSE,
  show.tests = TRUE,
  just.nested.pvalue = FALSE,
  nCores = NULL,
  nested.test = NULL,
  nsim = NULL,
  testcont = c("rank-sum test", "ANOVA"),
  testcat = c("Chi-squared", "Fisher"),
  full = TRUE,
  include_missing = FALSE,
  percentage = c("column", "row"),
  dropLevels = TRUE,
  excludeLevels = NULL,
  numobs = NULL,
  markup = TRUE,
  sanitize = TRUE,
  chunk_label
)

Arguments

data

dataframe containing data

covs

character vector with the names of columns to include in table

maincov

covariate to stratify table by

id

covariates to nest summary by

caption

character containing table caption (default is no caption)

tableOnly

Logical, if TRUE then a dataframe is returned, otherwise a formatted printed object is returned (default).

covTitle

character with the names of the covariate (predictor) column. The default is to leave this empty for output or, for table only output to use the column name 'Covariate'.

digits

number of digits for summarizing mean data

digits.cat

number of digits for the proportions when summarizing categorical data (default: 0)

nicenames

boolean indicating if you want to replace . and _ in strings with a space

IQR

boolean indicating if you want to display the inter quantile range (Q1,Q3) as opposed to (min,max) in the summary for continuous variables

all.stats

boolean indicating if all summary statistics (Q1,Q3 + min,max on a separate line) should be displayed. Overrides IQR.

pvalue

boolean indicating if you want p-values included in the table

effSize

boolean indicating if you want effect sizes included in the table. Can only be obtained if pvalue is also requested.

p.adjust

p-adjustments to be performed

unformattedp

boolean indicating if you would like the p-value to be returned unformatted (ie not rounded or prefixed with '<'). Best used with tableOnly = T and outTable function.

show.tests

boolean indicating if the type of statistical used should be shown in a column beside the p-values. Ignored if pvalue=FALSE.

just.nested.pvalue

boolean indicating if the just the nested p-value should be shown in a column, and not unnested p-value, unnested statistical tests and effect size. Overrides effSize and show.tests arguments.

nCores

number of cores to use for parallel processing if calculating the nested p-value (if provided).

nested.test

specifies test used for calculating nested p-value from afex::mixed function. Either parametric bootstrap method or likelihood ratio test method (default: "LRT"). Parametric bootstrap takes longer.

nsim

specifies number of simulations to use for calculating nested p-value with parametric bootstrap method used for nested.test (default: 1000).

testcont

test of choice for continuous variables,one of rank-sum (default) or ANOVA

testcat

test of choice for categorical variables,one of Chi-squared (default) or Fisher

full

boolean indicating if you want the full sample included in the table, ignored if maincov is NULL

include_missing

Option to include NA values of maincov. NAs will not be included in statistical tests

percentage

choice of how percentages are presented, one of column (default) or row

dropLevels

logical, indicating if empty factor levels be dropped from the output, default is TRUE.

excludeLevels

a named list of covariate levels to exclude from statistical tests in the form list(varname =c('level1','level2')). These levels will be excluded from association tests, but not the table. This can be useful for levels where there is a logical skip (ie not missing, but not presented). Ignored if pvalue=FALSE.

numobs

named list overriding the number of people you expect to have the covariate

markup

boolean indicating if you want latex markup

sanitize

boolean indicating if you want to sanitize all strings to not break LaTeX

chunk_label

only used if output is to Word to allow cross-referencing

Value

A character vector of the table source code, unless tableOnly=TRUE in which case a data frame is returned

See Also

covsum,fisher.test, chisq.test, wilcox.test, kruskal.test, anova, mixed and outTable

Examples

## Not run: 
# Example 1
data(ae)
rm_covsum_nested(data = ae, id = c("ae_detail", "Subject"), covs = c("AE_SEV_GD", 
"AE_ONSET_DT_INT"), maincov = "CTC_AE_ATTR_SCALE")

# Example 2: set variable labels and other options, save output with markup
data("ae")
lbls <- data.frame(c1=c('AE_SEV_GD','AE_ONSET_DT_INT'),
    c2=c('Adverse event severity grade','Adverse event onset date'))
ae$AE_SEV_GD <- as.numeric(ae$AE_SEV_GD)
ae <- reportRmd::set_labels(ae, lbls)
output_tab <- rm_covsum_nested(data = ae, id = c("ae_detail", "Subject"), 
    covs = c("AE_SEV_GD", "AE_ONSET_DT_INT"), maincov = "CTC_AE_ATTR_SCALE", 
    testcat = "Fisher", percentage = c("col"), show.tests = FALSE, pvalue = TRUE, 
    effSize = FALSE, full = TRUE, IQR = FALSE, nicenames = TRUE, sanitize = TRUE, 
    markup = TRUE, include_missing = TRUE, just.nested.pvalue = TRUE, 
    tableOnly = TRUE)
cat(reportRmd::outTable(tab=output_tab))
cat(reportRmd::outTable(output_tab, format="html"), file = paste("./man/tables/", 
    "output_tab.html", sep=""))
cat(reportRmd::outTable(output_tab, format="latex"), file = paste("./man/tables/", 
    "output_tab.tex", sep=""))

## End(Not run)

[Package BiostatsUHNplus version 0.0.10 Index]