View source: R/create-tidy-table-one_no-strata.R
create_tidy_table_one_no_strata | R Documentation |
Creates a tidy data frame of the results that can go into a "Table 1" of
summary descriptive statistics of a study sample. Inspiration for this is owed
to the tableone
package by Kazuki Yoshida.
create_tidy_table_one_no_strata(
data,
strata = NULL,
vars,
na_level = "(Missing)",
b_replicates = 2000,
...
)
data |
A data frame or tibble containing the variables to be summarized. |
strata |
NULL |
vars |
Character vector of the variable names to be summarized. If empty, then all variables in the given data frame are used. |
na_level |
Character string of the text to replace |
b_replicates |
an integer specifying the number of replicates used in the Monte Carlo test for Fisher's Exact test and Chi-square test. |
... |
Additional arguments. Not used. |
A tibble with the following results
Level of the stratifying variable
Variable/column name
Number of records
Numer of distinct values
Number of non-missing observations
Number of missing observations
Mean
Standard deviation
Minimum
25th percentile
Median
75th percentile
Maximum
Coefficient of variation
Shapiro-Wilkes test: p-value
Kolmogorov-Smirnov test: p-value
Anderson-Darling test for normality: p-value
Level of the variable
Total number in the variable's group
Total number in the variable group and strata
library(dplyr)
tab1 <- create_tidy_table_one_no_strata(data = pbc_mayo,
strata = NULL,
vars = c("time",
"status",
"trt",
"age",
"sex",
"ascites",
"hepato",
"spiders",
"edema",
"bili",
"chol",
"albumin",
"copper",
"alk_phos",
"ast",
"trig",
"platelet",
"protime",
"stage"))
dplyr::glimpse(tab1)
library(ggplot2) # diamonds data set
tab2 <- create_tidy_table_one_no_strata(data = diamonds,
vars = c("carat",
"cut",
"color",
"clarity",
"depth",
"table",
"price"))
dplyr::glimpse(tab2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.