R/plotly.R

Defines functions add_caption

#' @include shortcuts.R
#' 
#' @export
add_caption <- function(x, ..., .label = 'text') {
  ellipsis::check_dots_unnamed()
  labels <- lapply(
    tidyselect::vars_select(names(x), ...), 
    function(varname) g('{varname}: {x[[varname]]}')
  )
  
  x[[.label]] <- do.call(
    str_c,
    c(labels, sep = '\n')
  )
  x
}
gmega/megautils documentation built on Sept. 14, 2020, 8:06 p.m.