get_tableone | R Documentation |
S3 method for creating a table of summary statistics. The summary statistics can be used for presentation in tables such as table one or baseline and demography tables.
The summary statistics estimated are conditional on the variable type: continuous, binary, categorical, etc.
By default the following summary stats are calculated:
Numeric variables: mean, min, 25th-percentile, median, 75th-percentile, maximum, standard deviation
Factor variables: proportion of each factor level in the overall dataset
Default: number of unique values and number of missing values
get_tableone(
data,
strata = NULL,
overall = TRUE,
summary_function = summarize_short
)
## Default S3 method:
get_tableone(
data,
strata = NULL,
overall = TRUE,
summary_function = summarize_short
)
data |
The dataset to summarize as dataframe or tibble |
strata |
Stratifying/Grouping variable name(s) as character vector. If NULL, only overall results are returned |
overall |
If TRUE, the summary statistics for the overall dataset are also calculated |
summary_function |
A function defining summary statistics for numeric and categorical values |
It is possible to provide your own summary function. Please have a loot at summary for inspiration.
object of class tableone. That is a list of data specified summaries for all input variables.
All columns in the table will be summarized. If only some columns shall be used, please select only those variables prior to creating the summary table by using dplyr::select()
# Example using the ovarian data set
survival::ovarian %>%
dplyr::select(-fustat) %>%
dplyr::mutate(
age_group = factor(
dplyr::case_when(
age <= 50 ~ "<= 50 years",
age <= 60 ~ "<= 60 years",
age <= 70 ~ "<= 70 years",
TRUE ~ "> 70 years"
)
),
rx = factor(rx),
ecog.ps = factor(ecog.ps)
) %>%
dplyr::select(age, age_group, everything()) %>%
visR::get_tableone()
# Examples using ADaM data
# display patients in an analysis set
adtte %>%
dplyr::filter(SAFFL == "Y") %>%
dplyr::select(TRTA) %>%
visR::get_tableone()
## display overall summaries for demog
adtte %>%
dplyr::filter(SAFFL == "Y") %>%
dplyr::select(AGE, AGEGR1, SEX, RACE) %>%
visR::get_tableone()
## By actual treatment
adtte %>%
dplyr::filter(SAFFL == "Y") %>%
dplyr::select(AGE, AGEGR1, SEX, RACE, TRTA) %>%
visR::get_tableone(strata = "TRTA")
## By actual treatment, without overall
adtte %>%
dplyr::filter(SAFFL == "Y") %>%
dplyr::select(AGE, AGEGR1, SEX, EVNTDESC, TRTA) %>%
visR::get_tableone(strata = "TRTA", overall = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.