tbl_likert | R Documentation |
Create a table of ordered categorical variables in a wide format.
tbl_likert(
data,
statistic = ~"{n} ({p}%)",
label = NULL,
digits = NULL,
include = everything(),
sort = c("ascending", "descending")
)
data |
( |
statistic |
( |
label |
( |
digits |
( |
include |
( |
sort |
( |
a 'tbl_likert' gtsummary table
levels <- c("Strongly Disagree", "Disagree", "Agree", "Strongly Agree")
df_likert <- data.frame(
recommend_friend = sample(levels, size = 20, replace = TRUE) |> factor(levels = levels),
regret_purchase = sample(levels, size = 20, replace = TRUE) |> factor(levels = levels)
)
# Example 1 ----------------------------------
tbl_likert_ex1 <-
df_likert |>
tbl_likert(include = c(recommend_friend, regret_purchase)) |>
add_n()
tbl_likert_ex1
# Example 2 ----------------------------------
# Add continuous summary of the likert scores
list(
tbl_likert_ex1,
tbl_wide_summary(
df_likert |> dplyr::mutate(dplyr::across(everything(), as.numeric)),
statistic = c("{mean}", "{sd}"),
type = ~"continuous",
include = c(recommend_friend, regret_purchase)
)
) |>
tbl_merge(tab_spanner = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.