This is thoroughly experimental!

SOcode(x, data_object_name = "SOmap_data")

Arguments

x

: a map object as returned by SOmap, SOmanagement, SOleg, or SOgg

data_object_name

string: the name to use for the object that will hold the map data. See Examples, below

Value

A list with two elements: code contains R code that will draw the map, and SOmap_data (or whatever was passed as the data_object_name argument) contains any data required by that code

See also

Examples

if (FALSE) { # \dontrun{
  p <- SOmap()
  mapcode <- SOcode(p, data_object_name = "SOmap_data")

  ## write this code to a file
  my_R_file <- tempfile(fileext = ".R")
  writeLines(mapcode$code, con = my_R_file)

  ## you can edit the code in that file if desired

  ## save the data
  my_data_file <- tempfile(fileext = ".rds")
  saveRDS(mapcode$SOmap_data, my_data_file)

  ## later on, we can re-load the data and execute the code
  SOmap_data <- readRDS(my_data_file)
  source(my_R_file)

  ## or just to show that this works, evaluate the returned code directly against its data
  with(mapcode, for (codeline in code) eval(parse(text = codeline)))
} # }