View source: R/verify_palettes.R
verify_palettes | R Documentation |
Verify the integrity of the palettes object
verify_palettes(palettes, column_info, data)
palettes |
A named list of palettes. Each entry in
|
column_info |
A data frame describing which columns in
|
data |
A data frame with items by row and features in the columns.
Must contain one column named |
The palettes object with all expected columns.
library(tibble)
library(grDevices)
library(RColorBrewer)
# explicit form
data <- tribble(
~id, ~name, ~x, ~y,
"foo", "Foo", 0.5, 0.7,
"bar", "Bar", 1.0, 0.1
)
column_info <- tribble(
~id, ~geom, ~palette,
"name", "text", NA,
"foo", "funkyrect", "pal1",
"bar", "funkyrect", "pal2"
)
palettes <- list(
pal1 = rev(brewer.pal(9, "Greys")[-1]),
pal2 = rev(brewer.pal(9, "Reds")[-8:-9])
)
verify_palettes(palettes, column_info, data)
# implicit palettes
palettes <- list(
pal1 = "Greys",
pal2 = "Reds"
)
verify_palettes(palettes, column_info, data)
# passing a tibble should also work (for backwards compatibility)
palettes <- tribble(
~palette, ~colours,
"pal1", rev(brewer.pal(9, "Greys")[-1]),
"pal2", rev(brewer.pal(9, "Reds")[-8:-9])
)
verify_palettes(palettes, column_info, data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.