diff --git a/DESCRIPTION b/DESCRIPTION index 3afa846..6eff039 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,7 +14,7 @@ Encoding: UTF-8 URL: https://bluefoxr.github.io/COINr/ BugReports: https://github.com/bluefoxr/COINr/issues LazyData: true -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Imports: openxlsx (>= 4.2.3), stats, diff --git a/R/plot_framework.R b/R/plot_framework.R index b08630f..28be80f 100644 --- a/R/plot_framework.R +++ b/R/plot_framework.R @@ -25,6 +25,7 @@ #' @param text_colour Colour of label text - default `"white"`. #' @param text_size Text size of labels, default 2.5 #' @param transparency If `TRUE`, levels below `colour_level` are differentiated with some transparency. +#' @param text_label Text labelling of segments: either `"iCode"` or `"iName"` #' #' @importFrom rlang .data #' @@ -38,7 +39,8 @@ #' @return A ggplot2 plot object #' @export plot_framework <- function(coin, type = "sunburst", colour_level = NULL, - text_colour = NULL, text_size = NULL, transparency = TRUE){ + text_colour = NULL, text_size = NULL, transparency = TRUE, + text_label = "iCode"){ # CHECKS ------------------------------------------------------------------ @@ -49,6 +51,10 @@ plot_framework <- function(coin, type = "sunburst", colour_level = NULL, iMeta <- coin$Meta$Ind[!is.na(coin$Meta$Ind$Level), ] maxlev <- coin$Meta$maxlev + if(text_label %nin% c("iCode", "iName")){ + stop("text_label must be either 'iCode' or 'iName'") + } + # DEFAULTS ---------------------------------------------------------------- text_colour <- set_default(text_colour, "white") @@ -116,7 +122,7 @@ plot_framework <- function(coin, type = "sunburst", colour_level = NULL, plt <- ggplot2::ggplot(iMeta, ggplot2::aes(x = .data$Level, y = .data$EffWeight, fill = .data$colourcol, - label = .data$iCode)) + label = .data[[text_label]])) # bars if(transparency){ diff --git a/man/plot_framework.Rd b/man/plot_framework.Rd index 4945a3b..58d2515 100644 --- a/man/plot_framework.Rd +++ b/man/plot_framework.Rd @@ -10,7 +10,8 @@ plot_framework( colour_level = NULL, text_colour = NULL, text_size = NULL, - transparency = TRUE + transparency = TRUE, + text_label = "iCode" ) } \arguments{ @@ -25,6 +26,8 @@ plot_framework( \item{text_size}{Text size of labels, default 2.5} \item{transparency}{If \code{TRUE}, levels below \code{colour_level} are differentiated with some transparency.} + +\item{text_label}{Text labelling of segments: either \code{"iCode"} or \code{"iName"}} } \value{ A ggplot2 plot object