CCTable: Summary table for univariate analysis of case control studies

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/CCTable_.R

Description

CCTable is used for univariate analysis of case control studies with several exposures. The results are summarised in one table with one row per exposure making comparisons between exposures easier and providing a useful table for integrating into reports. Note that all variables need to be numeric and binary and coded as "0" and "1".

The results of this function contain: The name of exposure variables, the total number of cases, the number of exposed cases, the percentage of exposed among cases, the number of controls, the number of exposed controls, the percentage of exposed among controls, odds ratios, 95%CI intervals, p-values.

You can optionally choose to display the Fisher's exact p-value instead of the Chi squared p-value, with the option exact = TRUE.

You can specify the sort order, with the option sort = "or" to order by odds ratios. The default sort order is by p-values.

The option full = TRUE provides you with useful formatting information, which can be handy if you're using "markdown".

Usage

1
CCTable(x, cases, exposure = c(), exact = FALSE, sort = "pvalue", full = FALSE)

Arguments

x

data.frame

cases

character - cases binary variable (0 / 1)

exposure

character vector - exposure variables

exact

boolean - TRUE if you want the Fisher's exact p-value instead of CHI2

sort

character - [pvalue, or, pe] sort by pvalue (default) or by odds ratio, or by percent exposed

full

boolean - TRUE if you need to display useful values for formatting

Details

The results of this function contain: The name of exposure variables, the total number of cases, the number of exposed cases, the percentage of exposed among cases, the number of controls, the number of exposed controls, the percentage of exposed among controls, odds ratios, 95%CI intervals, p-values.

You can optionally choose to display the Fisher???s exact p-value instead of the Chi squared p-value, with the option exact = TRUE.

You can specify the sort order, with the option sort=???or??? to order by odds ratios. The default sort order is by p-values.

The option "full = TRUE" provides you with useful formatting information, which can be handy if you're using "markdown".

Value

list :

df

data.frame - results table

digits

integer vector - digit number displayed for kable/xtable

align

character - alignment for kable/xtable

Note

- You can use the lowercase command "cctable" instead of "CCTable"

Author(s)

jean.pierre.decorps@gmail.com

References

cctable for Stata by *Gilles Desve* and *Peter Makary*.

See Also

CC, CCInter

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(EpiStats)

data(Tiramisu)
df <- Tiramisu

# You can see the association between several exposures and being ill.
cctable(df, "ill", exposure=c("sex", "wmousse", "tira", "beer", "mousse"))

# By storing results in res, you can also use individual elements of the results.
# For example if you would like to view a particular odds ratio,
# you can view it by typing (for example):

res = CCTable(df, "ill", exposure = c("sex", "wmousse", "tira", "beer", "mousse"), exact=TRUE)
res$df$`Odds Ratio`[1]

Example output

Loading required package: epiR
Loading required package: survival
Package epiR 1.0-15 is loaded
Type help(epi.about) for summary information
Type browseVignettes(package = 'epiR') to learn how to use epiR for applied epidemiological analyses


Loading required package: dplyr

Attaching package:dplyrThe following objects are masked frompackage:stats:

    filter, lag

The following objects are masked frompackage:base:

    intersect, setdiff, setequal, union

$df
        Tot.Cases Exposed     % Tot.Ctrls Exposed     %    OR CI ll  CI ul
wmousse        98      49 50.00       179      23 12.85  6.78  3.62  12.83
tira          101      94 93.07       185      27 14.59 78.58 31.45 217.15
mousse        103      81 78.64       186      42 22.58 12.62  6.80  23.70
beer           99      30 30.30       172      76 44.19  0.55  0.31   0.95
sex           103      50 48.54       188     102 54.26  0.80  0.48   1.32
        p(Chi2)
wmousse   0.000
tira      0.000
mousse    0.000
beer      0.024
sex       0.351

NULL

EpiStats documentation built on June 7, 2021, 5:06 p.m.