library("CIDAtools")
# Synthetic data
df = data.frame(
`Age` = c(10,12,14,18,20,19,28,33, rep(NA, 4)),
`Sex` = c(rep("Female", 4), rep("Male", 4), rep(NA, 4)),
`Smoking Status` = c(rep('Former', 2), rep('Current', 2), rep('Never', 4), rep(NA, 4)),
`IL-8` = rnorm(12, 35, sd = 7),
`Group` = c(rep('Control', 4), rep('Heart Disease', 4), rep('Lung Disease', 4)),
check.names = FALSE
)
# Table 1 with no p-values
cida_table1(data = df,
includeVars = c("Age", "Sex", "Smoking Status", "IL-8"),
stratifyBy = "Group",
group_labels = c("Group"),
group_label_span = c(3),
caption = "TABLE 1",
footnote = "My table 1",
include_total = FALSE,
compute_pval = FALSE,
nonParametricVars = NULL,
exportWord = FALSE)Group |
|||
|---|---|---|---|
| Control (N=4) |
Heart Disease (N=4) |
Lung Disease (N=4) |
|
My table 1 | |||
| Age | |||
| Mean (SD) | 13.5 (3.42) | 25.0 (6.68) | NA (NA) |
| Median [Min, Max] | 13.0 [10.0, 18.0] | 24.0 [19.0, 33.0] | NA [NA, NA] |
| Missing | 0 (0%) | 0 (0%) | 4 (100%) |
| Sex | |||
| Female | 4 (100%) | 0 (0%) | 0 (0%) |
| Male | 0 (0%) | 4 (100%) | 0 (0%) |
| Missing | 0 (0%) | 0 (0%) | 4 (100%) |
| Smoking Status | |||
| Current | 2 (50.0%) | 0 (0%) | 0 (0%) |
| Former | 2 (50.0%) | 0 (0%) | 0 (0%) |
| Never | 0 (0%) | 4 (100%) | 0 (0%) |
| Missing | 0 (0%) | 0 (0%) | 4 (100%) |
| IL-8 | |||
| Mean (SD) | 35.1 (10.5) | 38.7 (7.63) | 31.7 (5.29) |
| Median [Min, Max] | 38.1 [20.6, 43.5] | 41.2 [27.6, 44.7] | 31.8 [26.2, 36.9] |
# Table 1 with p-values, no mean, no percent missing
cida_table1(data = df,
includeVars = c("Age", "Sex", "Smoking Status", "IL-8"),
stratifyBy = "Group",
group_labels = c("", "Group", ""),
group_label_span = c(1, 3, 1),
caption = "TABLE 1",
footnote = "My table 1",
exclude_mean = TRUE,
exclude_missing = TRUE,
include_total = TRUE,
compute_pval = TRUE,
nonParametricVars = NULL,
exportWord = FALSE)Group |
||||||
|---|---|---|---|---|---|---|
| Total (N=12) |
Control (N=4) |
Heart Disease (N=4) |
Lung Disease (N=4) |
p-value | ||
My table 1
p-values computed as follows: Parametric Numeric data with 2 groups -- t-test Numeric data with more than 2 groups -- ANOVA Non-parametric Numeric data with 2 groups -- Wilcoxon-test Numeric data with more than 2 groups -- Kruskal-Wallis test Categorical data with any cell value < 5 -- Fishers exact test Categerical data with all cell values >= 5 -- Chi-square test of independence | ||||||
| Age | ||||||
| Median [Min, Max] | 18.5 [10.0, 33.0] | 13.0 [10.0, 18.0] | 24.0 [19.0, 33.0] | NA [NA, NA] | 0.022 | |
| Sex | ||||||
| Female | 4 (33.3%) | 4 (100%) | 0 (0%) | 0 (0%) | 0.029 | |
| Male | 4 (33.3%) | 0 (0%) | 4 (100%) | 0 (0%) | ||
| Smoking Status | ||||||
| Current | 2 (16.7%) | 2 (50.0%) | 0 (0%) | 0 (0%) | 0.029 | |
| Former | 2 (16.7%) | 2 (50.0%) | 0 (0%) | 0 (0%) | ||
| Never | 4 (33.3%) | 0 (0%) | 4 (100%) | 0 (0%) | ||
| IL-8 | ||||||
| Median [Min, Max] | 36.2 [20.6, 44.7] | 38.1 [20.6, 43.5] | 41.2 [27.6, 44.7] | 31.8 [26.2, 36.9] | 0.501 | |
# Table 1 styling the output
# You can also rename the variables like this (name in data = new name)
cida_table1(data = df,
includeVars = c("Age" = "age",
"Sex" = "sex",
"Smoking Status" = "smoking",
"IL-8"= "Interleukin 8"),
stratifyBy = "Group",
group_labels = c("", "Group", ""),
group_label_span = c(1, 3, 1),
caption = "TABLE 1",
footnote = "My table 1",
exclude_mean = TRUE,
exclude_missing = TRUE,
include_total = TRUE,
compute_pval = TRUE,
nonParametricVars = c("Age", "IL-8"), # Uses original name
exportWord = FALSE)Group |
||||||
|---|---|---|---|---|---|---|
| Total (N=12) |
Control (N=4) |
Heart Disease (N=4) |
Lung Disease (N=4) |
p-value | ||
My table 1
p-values computed as follows: Parametric Numeric data with 2 groups -- t-test Numeric data with more than 2 groups -- ANOVA Non-parametric Numeric data with 2 groups -- Wilcoxon-test Numeric data with more than 2 groups -- Kruskal-Wallis test Categorical data with any cell value < 5 -- Fishers exact test Categerical data with all cell values >= 5 -- Chi-square test of independence | ||||||
| age | ||||||
| Median [Min, Max] | 18.5 [10.0, 33.0] | 13.0 [10.0, 18.0] | 24.0 [19.0, 33.0] | NA [NA, NA] | 0.021 | |
| sex | ||||||
| Female | 4 (33.3%) | 4 (100%) | 0 (0%) | 0 (0%) | 0.029 | |
| Male | 4 (33.3%) | 0 (0%) | 4 (100%) | 0 (0%) | ||
| smoking | ||||||
| Current | 2 (16.7%) | 2 (50.0%) | 0 (0%) | 0 (0%) | 0.029 | |
| Former | 2 (16.7%) | 2 (50.0%) | 0 (0%) | 0 (0%) | ||
| Never | 4 (33.3%) | 0 (0%) | 4 (100%) | 0 (0%) | ||
| Interleukin 8 | ||||||
| Median [Min, Max] | 36.2 [20.6, 44.7] | 38.1 [20.6, 43.5] | 41.2 [27.6, 44.7] | 31.8 [26.2, 36.9] | 0.39 | |
# Tables are html so you can customize them using html and css
cida_table1(data = df,
includeVars = c("Age" = "age",
"Sex" =
"<span style =
'background-color:pink;'>sex</span>", # Highlight pink
"Smoking Status" =
"<span style='color:purple;
font-family:Snell Roundhand;
font-size:1.5em;
font-weight:900;'>smoking status</span>",
"IL-8"=
"Interleukin 8β"), # β is html for greek lowercase beta
stratifyBy = "Group",
group_labels = c("", "Group", ""),
group_label_span = c(1, 3, 1),
caption = "TABLE 1",
footnote = "My table 1",
exclude_mean = TRUE,
exclude_missing = TRUE,
include_total = TRUE,
compute_pval = TRUE,
nonParametricVars = NULL,
exportWord = FALSE)Group |
||||||
|---|---|---|---|---|---|---|
| Total (N=12) |
Control (N=4) |
Heart Disease (N=4) |
Lung Disease (N=4) |
p-value | ||
My table 1
p-values computed as follows: Parametric Numeric data with 2 groups -- t-test Numeric data with more than 2 groups -- ANOVA Non-parametric Numeric data with 2 groups -- Wilcoxon-test Numeric data with more than 2 groups -- Kruskal-Wallis test Categorical data with any cell value < 5 -- Fishers exact test Categerical data with all cell values >= 5 -- Chi-square test of independence | ||||||
| age | ||||||
| Median [Min, Max] | 18.5 [10.0, 33.0] | 13.0 [10.0, 18.0] | 24.0 [19.0, 33.0] | NA [NA, NA] | 0.022 | |
| sex | ||||||
| Female | 4 (33.3%) | 4 (100%) | 0 (0%) | 0 (0%) | 0.029 | |
| Male | 4 (33.3%) | 0 (0%) | 4 (100%) | 0 (0%) | ||
| smoking status | ||||||
| Current | 2 (16.7%) | 2 (50.0%) | 0 (0%) | 0 (0%) | 0.029 | |
| Former | 2 (16.7%) | 2 (50.0%) | 0 (0%) | 0 (0%) | ||
| Never | 4 (33.3%) | 0 (0%) | 4 (100%) | 0 (0%) | ||
| Interleukin 8β | ||||||
| Median [Min, Max] | 36.2 [20.6, 44.7] | 38.1 [20.6, 43.5] | 41.2 [27.6, 44.7] | 31.8 [26.2, 36.9] | 0.501 | |
# You can add icons if you like
cida_table1(data = df,
includeVars = c("Age" = "age", "Sex" = "sex",
"Smoking Status" =
"<link rel='stylesheet'
href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'>
<span>Smoking Status </span>
<i class='fa fa-medkit'></i>", # Medkit icon
"IL-8"= "Interleukin 8β"),
stratifyBy = "Group",
group_labels = c("", "Group", ""),
group_label_span = c(1, 3, 1),
caption = "TABLE 1",
footnote = "My table 1",
exclude_mean = TRUE,
exclude_missing = TRUE,
include_total = TRUE,
compute_pval = TRUE,
nonParametricVars = NULL,
exportWord = FALSE)Group |
||||||
|---|---|---|---|---|---|---|
| Total (N=12) |
Control (N=4) |
Heart Disease (N=4) |
Lung Disease (N=4) |
p-value | ||
My table 1
p-values computed as follows: Parametric Numeric data with 2 groups -- t-test Numeric data with more than 2 groups -- ANOVA Non-parametric Numeric data with 2 groups -- Wilcoxon-test Numeric data with more than 2 groups -- Kruskal-Wallis test Categorical data with any cell value < 5 -- Fishers exact test Categerical data with all cell values >= 5 -- Chi-square test of independence | ||||||
| age | ||||||
| Median [Min, Max] | 18.5 [10.0, 33.0] | 13.0 [10.0, 18.0] | 24.0 [19.0, 33.0] | NA [NA, NA] | 0.022 | |
| sex | ||||||
| Female | 4 (33.3%) | 4 (100%) | 0 (0%) | 0 (0%) | 0.029 | |
| Male | 4 (33.3%) | 0 (0%) | 4 (100%) | 0 (0%) | ||
| Smoking Status | ||||||
| Current | 2 (16.7%) | 2 (50.0%) | 0 (0%) | 0 (0%) | 0.029 | |
| Former | 2 (16.7%) | 2 (50.0%) | 0 (0%) | 0 (0%) | ||
| Never | 4 (33.3%) | 0 (0%) | 4 (100%) | 0 (0%) | ||
| Interleukin 8β | ||||||
| Median [Min, Max] | 36.2 [20.6, 44.7] | 38.1 [20.6, 43.5] | 41.2 [27.6, 44.7] | 31.8 [26.2, 36.9] | 0.501 | |