diff --git a/R/plot_hbar.R b/R/plot_hbar.R index 5e13a8e6..5e71d745 100644 --- a/R/plot_hbar.R +++ b/R/plot_hbar.R @@ -34,7 +34,8 @@ vertical_stacked_bars <- function(data, t.size = 10, l.color = "black", l.size = .5, - draw.lines = TRUE) { + draw.lines = TRUE, + label.str="{n}\n{round(100 * p,0)}%") { if (is.null(group)) { df.table <- data[c(score, group, strata)] |> dplyr::mutate("All" = 1) |> @@ -79,7 +80,8 @@ vertical_stacked_bars <- function(data, y = p_prev + 0.49 * p, color = as.numeric(score) > contrast_cut, # label = paste0(sprintf("%2.0f", 100 * p),"%"), - label = sprintf("%2.0f", 100 * p) + # label = sprintf("%2.0f", 100 * p) + label = glue::glue(label.str) ) ) + ggplot2::labs(fill = score_label) + diff --git a/man/vertical_stacked_bars.Rd b/man/vertical_stacked_bars.Rd index af09a99b..52f3c5c0 100644 --- a/man/vertical_stacked_bars.Rd +++ b/man/vertical_stacked_bars.Rd @@ -12,7 +12,8 @@ vertical_stacked_bars( t.size = 10, l.color = "black", l.size = 0.5, - draw.lines = TRUE + draw.lines = TRUE, + label.str = "{n}\\n{round(100 * p,0)}\%" ) } \arguments{