stat.col: Statistical Testing

View source: R/Table1.R

stat.colR Documentation

Statistical Testing

Description

This function produces vectors of p-values and tests for addition via ptype= to a summary table generated with make.table. P-values are rounded to three decimal places or formatted as '<0.001' as appropriate. The name of the test is printed if requested with pname=TRUE.

Usage

stat.col(var, strat, ptype, pname, output)

Arguments

var

Variable input. Required.

strat

Column stratifying variable. Required for two-sample tests.

ptype

Test requested to compute p-value. Required.

't.oneway'

One-sample t-test

'wilcox.oneway'

One-sample test for median=0

'prop.oneway'

Binomial test for equal proportions (prop=0.5)

'chisq'

Chi-square test

'fisher'

Fisher's exact test

'ttest'

t-test

'anova'

One-way ANOVA

'kruskal'

Kruskal-Wallis test

'wilcox'

Wilcoxon rank-sum test

'ttest.pair'

Paired t-test

'wilcox.pair'

Wilcoxon signed-rank test

'mcnemar'

McNemar's test

pname

If TRUE then the name of the statistical test used will be printed below the p-value. Optional; defaults to FALSE.

output

Type of output, passed from make.table or quick.table. Optional; defaults to "plain".

Value

Returns a vector with a p-value and the name of the test used, if requested, to be added to a summary data frame.

Author(s)

Erica Wozniak

See Also

Table1 make.table quick.table cat.var cont.var out.plain out.latex out.html

Examples

library(survival)
attach(pbc)

##Default output
stat.col(var=bili, 
         strat=sex, 
         ptype='ttest')
        
##Print test
stat.col(var=bili, 
         strat=sex, 
         ptype='ttest',
         pname=TRUE)
        
##The ptype= and pname= options in summary functions call stat.col
#Results are automatically added to the summary table
cat.var(var=hepato, 
        strat=sex, 
        rownames=c('Not present', 'Present'),
        header=c('Hepatomegaly'),
        ptype='chisq',
        pname=TRUE
        )       

emwozniak/Table1 documentation built on Oct. 5, 2022, 12:20 a.m.