prep_sigmark | R Documentation |
Helper function to prepare a summarized data frame for significance markers with geom_sigmark
prep_sigmark(df, test_df, subgroups, result, colours = NULL, percent, vs_rest)
df |
A data frame with the summarized data to be charted |
test_df |
The output of either |
subgroups |
Grouping vector |
result |
Result vector (either proportions or mean values) |
colours |
A vector of colours associated with the subgroup levels. Not needed if |
percent |
A logical indicating whether the results are proportions or not |
vs_rest |
A logical indicating whether the vs_rest argument in |
A tibble ready for ggplot2 chart with a geom_sigmark()
layer.
mydf <- data.frame(smokers = c(rbinom(100, 1, .8),
rbinom(70, 1, 0.7),
rbinom(50, 1, 0.6)),
region = c(rep("A", 100), rep("B", 70), rep("C", 50)))
test_res <- pairwise_prop_test(mydf, smokers, region)
colour_vec <- c("A" = "red", "B" = "blue", "C" = "green")
library(dplyr, warn.conflicts = FALSE)
mydf |>
count(smokers, region) |>
filter(smokers == 1) |>
mutate(perc = n / sum(n)) |>
prep_sigmark(test_res, region, perc, colour_vec, percent = TRUE, vs_rest = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.