R/farv_rgb_hex.R

Defines functions farv_rgb_hex

Documented in farv_rgb_hex

#' HEX from RGB.
#'
#' Converts a data frame with RGB colors to a vector of HEX collors.
#'
#'
#' @export
#' @param df A data frame with RGB color in the form created with rgb_tibble.
#' @return A vector of HEX colors.
farv_rgb_hex <- function(df){
  cols <- c(1, 2, 3)
  out <- purrr::modify(df, as.hexmode) %>%
  tidyr::unite(cols, col="hex", sep="") %>%
  purrr::map_df(~paste0("#", .x)) %>%
  dplyr::pull()

  out
}
davidbaniadam/farver documentation built on July 12, 2019, 11:51 p.m.