R/rand_pal_c.R

Defines functions rand_pal_c

Documented in rand_pal_c

#' Get Random Palette from {paletteer}
#'
#' This function pulls a random continuous palette from {paletteer} that has a minimum length. It returns the name of the palette and the hexcodes.
#'
#' @description Get Random Continuous Color Palette
#' @param n_colors The minimum number of colors in the palette.
#' @return A list of the package name and the colors
#' @examples
#'
#' rand_pal_c(n_colors = 6)
#'
#' @export


rand_pal_c <- function(n_colors = 3){

  available_pals <- paletteer::palettes_c_names

  n_pals <- nrow(available_pals)

  my_pal_no <- floor(runif(1, min = 0, max = n_pals))

  my_pal <- available_pals %>%
    dplyr::slice(my_pal_no)

  my_pal_name <- paste0(my_pal$package, "::", my_pal$palette)

  return(list(my_pal_name, paletteer::paletteer_c(my_pal_name, n = n_colors)))
}
simscr/crsp documentation built on Sept. 29, 2023, 7:09 p.m.