Table1: Create journal style characteristic table

Description Usage Arguments Details Value Examples

View source: R/Table1.R

Description

Create journal style characteristic table

Usage

1
2
Table1(data, numcol = NULL, catcol = NULL, exp_var, output = NULL,
  overall = TRUE, esdigits = 1, pdigits = 3, eps = 0.001)

Arguments

data

A dataframe including the exposure variable.

numcol

A vector of numerical column names in character. Default to NULL.

catcol

A vector of categorical column names in character. Default to NULL.

exp_var

String of main exposure variable name

output

String of path to store the output word file. For example, 'Table1.doc' or 'Table1.rtf'

overall

Whether to add a column for overall subjects. Default to TRUE

esdigits

Controlling the SD, mean and percent digits. Default to 1.

pdigits

Controlling the significant p-value digits. Default to 1.

eps

P-value tolerane. Those less than eps are formatted as "< [eps]". Default to 0.001

Details

Table1 function

This function helps to create journal style "Table 1" for numerical/continuous and categorical columns.
For numerical/continuous columns, the results will be mean(SD). P-value is computed from Kruskal-Wallis Rank Sum test statistic.
For categorical columns, the results will be n(%). P-value is computed from chi-square test statistic.
The output will be saved in word file.

Value

If output is not specified, a dataframe will be returned. Otherwise, a rtf file will be saved in the specified path.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
df = data.frame(
a = sample(1:100, 100, TRUE),
b = sample(c('Y', 'N', 'UNK'), 100, TRUE, prob=c(0.5, 0.3, 0.2)),
c = sample(1:100, 100, TRUE),
d = sample(c('Exposed', 'Unexposed'), 100, TRUE, prob=c(0.6, 0.4)))

Table1(df, c('a', 'c'), 'b', 'd', overall=TRUE)

Name     Overall (n=100)  Exposed (n=60)  Unexposed (n=40)  P_val
b                                                           0.804
N        28 (28)          18 (30)         10 (25)
UNK      27 (27)          15 (25)         12 (30)
Y        45 (45)          27 (45)         18 (45)
a        54.2 (28.6)      52.2 (28.3)     57.2 (29.2)       0.408
c        50.1 (31)        50.1 (29.7)     50.1 (33.3)       0.935

acmilannesta/JReport documentation built on Feb. 19, 2020, 4:24 a.m.