Conveniently store custom themes across R sessions using a persistent caching mechanism. This function creates a cache directory to save the themes as individual RDS files, and asks permission to the user before writing.

city_themes(name,
            theme = NULL,
            force = FALSE,
            remove = FALSE)

Arguments

name

a character vector of the theme to save or extract.

theme

a list containing theme options to store.

force

logical. Whether to overwrite a theme if it already exists.

remove

logical. Whether to remove the theme from the cache.

Value

A list of class rcityviewsTheme containing the theme options.

Author

Koen Derks, koen-derks@hotmail.com

Examples

if (FALSE) { # \dontrun{
# Custom theme (black, beige and white), streets only
myTheme <- list(
  colors = list(
    background = "#232323",
    water = "#232323",
    landuse = "#232323",
    contours = "#232323",
    streets = "#d7b174",
    rails = c("#d7b174", "#232323"),
    buildings = "#232323",
    text = "#ffffff",
    waterlines = "#232323"
  ),
  font = list(
    family = "serif",
    face = "bold",
    scale = 1,
    append = "\u2014"
  ),
  size = list(
    borders = list(
      contours = 0.15,
      water = 0.4,
      canal = 0.5,
      river = 0.6
    ),
    streets = list(
      path = 0.2,
      residential = 0.3,
      structure = 0.35,
      tertiary = 0.4,
      secondary = 0.5,
      primary = 0.6,
      motorway = 0.8,
      rails = 0.75,
      runway = 3
    )
  )
)
# Store the custom theme in the cache
city_themes("blackandyellow", theme = myTheme)
# Retreive the custom theme from the cache
city_themes("blackandyellow")
# Remove the custom theme from the cache
city_themes("blackandyellow", remove = TRUE)
} # }