cida_table1 | R Documentation |
This is a function created to provide characteristics of a study group with an option to stratify by some variable (usually an exposure).
cida_table1(
data,
includeVars,
stratifyBy,
group_labels,
group_label_span,
caption = NULL,
footnote = NULL,
include_total = TRUE,
exclude_mean = FALSE,
exclude_missing = FALSE,
compute_pval = FALSE,
nonParametricVars = NULL,
exportWord = FALSE,
useSciNotation = FALSE
)
data |
A data frame with data |
includeVars |
A vector of variable names you wish to include in the table. |
stratifyBy |
The group by which you wish to stratify your table |
group_labels |
Higher level labels for you stratified groups |
group_label_span |
The span of columns for each group in 'group_labels' |
caption |
Optional; Adds a caption to the table |
footnote |
Optional; Adds a footnote to the table |
include_total |
Bool; Default |
exclude_mean |
Bool; Default |
exclude_missing |
Bool; Default |
compute_pval |
Bool; Default |
nonParametricVars |
Vector; of the variable names you would like non-parametric testing to be conducted on for p-values returned |
exportWord |
Bool; whether to export the table in a nice format into word |
useSciNotation |
Bool; Use scientific notation for large/small continuous variables |
an html table with N and percentages for categorical variables, mean , SD, Median, and Range for numeric variables. Returns p-values if specified.
# 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)
# 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)
# 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)
# 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)
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.