From 4861a4c59db6f710590ded2002167a8d0eb78f1f Mon Sep 17 00:00:00 2001 From: gnoblet Date: Wed, 21 Dec 2022 11:32:37 -0500 Subject: [PATCH] Wrap text arg --- R/bar.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/bar.R b/R/bar.R index 24ddae8..db4bfd3 100644 --- a/R/bar.R +++ b/R/bar.R @@ -21,7 +21,7 @@ #' @return A bar chart #' #' @export -bar <- function(df, x, y, group = NULL, flip = TRUE, percent = TRUE, position = "dodge", alpha = 1, x_title = NULL, y_title = NULL, group_title = NULL, title = NULL, subtitle = NULL, caption = NULL, add_text = FALSE, add_text_suffix = "", theme = theme_reach()){ +bar <- function(df, x, y, group = NULL, flip = TRUE, percent = TRUE, position = "dodge", alpha = 1, x_title = NULL, y_title = NULL, group_title = NULL, title = NULL, subtitle = NULL, caption = NULL, add_text = FALSE, add_text_suffix = "", title_wrap = 60, subtitle_wrap = 60, caption_wrap = 120, theme = theme_reach()){ # To do : # - automate bar width and text size, or at least give the flexibility and still center text @@ -41,9 +41,9 @@ bar <- function(df, x, y, group = NULL, flip = TRUE, percent = TRUE, position = # Add title, subtitle, caption, x_title, y_title g <- g + ggplot2::labs( - title = title, - subtitle = subtitle, - caption = caption, + title = stringr::str_wrap(title, title_wrap), + subtitle = stringr::str_wrap(subtitle, subtitle_wrap), + caption = stringr::str_wrap(caption, caption_wrap), x = x_title, y = y_title, color = group_title,