diff --git a/NEWS.md b/NEWS.md index c06aa71..a8539f9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ ## Minor changes +- Arguments (`digits` and `table.font.size`) added to `ggsummarystats()` for changing the summary table decimal place and text size (#341). - Now, the x-axis tick label names correctly align with the corresponding ticks when the rotation angle of the texts is set to 90. This is automatically achieved by setting internally `vjust = 0.5` (#301). ## Bug fixes diff --git a/R/ggsummarystats.R b/R/ggsummarystats.R index cf3cc7b..c95a0f3 100644 --- a/R/ggsummarystats.R +++ b/R/ggsummarystats.R @@ -8,6 +8,7 @@ NULL #' @inheritParams ggboxplot #' @param digits integer indicating the number of decimal places (round) to be #' used. +#' @param table.font.size the summary table font size. #' @param position Position adjustment, either as a string, or the result of a #' call to a position adjustment function. #' @param summaries summary stats to display in the table. Possible values are @@ -131,7 +132,8 @@ ggsummarystats <- function(data, x, y, summaries = c("n", "median", "iqr"), ggfunc = ggboxplot, color = "black", fill = "white", palette = NULL, facet.by = NULL, free.panels = FALSE, labeller = "label_value", - heights = c(0.80, 0.20), ggtheme = theme_pubr(), ...) { + heights = c(0.80, 0.20), digits = 0, table.font.size = 3, + ggtheme = theme_pubr(), ...) { if (missing(ggtheme) & !is.null(facet.by)) { ggtheme <- theme_pubr(border = TRUE) } @@ -201,7 +203,8 @@ ggsummarystats_core <- function(data, x, y, summaries = c("n", "median", "iqr"), ggfunc = ggboxplot, color = "black", fill = "white", palette = NULL, ggtheme = theme_pubr(), heights = c(0.80, 0.20), - facet.by = NULL, free.panels = FALSE, labeller = "label_value", ...) { + facet.by = NULL, free.panels = FALSE, labeller = "label_value", + digits = 0, table.font.size = 3,...) { groups <- c(x, color, fill, facet.by) %>% unique() %>% intersect(colnames(data)) @@ -224,7 +227,8 @@ ggsummarystats_core <- function(data, x, y, summaries = c("n", "median", "iqr"), x = x, y = summaries, color = color, palette = palette, legend = "none", ggtheme = ggtheme, - facet.by = table.facet.by, labeller = labeller + facet.by = table.facet.by, labeller = labeller, + digits = digits, size = table.font.size ) + clean_table_theme() diff --git a/man/ggsummarystats.Rd b/man/ggsummarystats.Rd index e5b290a..ab4dc4c 100644 --- a/man/ggsummarystats.Rd +++ b/man/ggsummarystats.Rd @@ -35,6 +35,8 @@ ggsummarystats( free.panels = FALSE, labeller = "label_value", heights = c(0.8, 0.2), + digits = 0, + table.font.size = 3, ggtheme = theme_pubr(), ... ) @@ -100,6 +102,8 @@ argument \code{facet.by} is specified.} \item{heights}{a numeric vector of length 2, specifying the heights of the main and the summary table, respectively.} +\item{table.font.size}{the summary table font size.} + \item{legend}{character specifying legend position. Allowed values are one of c("top", "bottom", "left", "right", "none"). To remove the legend use legend = "none".}