| writeSets | R Documentation | 
Function to write a set declaration in GAMS syntax given either a a character vector or a data.frame (latter to represent a mapping set)
writeSets(sets, file = NULL)
| sets | a list of sets where every set is another list consisting of three entries: name (set name as character), desc (set description as character) and items (set elements, either as character vector or data.frame) | 
| file | Name of the file the set declarations should be written to. If NULL the result will just be returned by the function. The file must exist and contain a line of the form "##### R SECTION START (SETS) #####" followed by a line of the form ##### R SECTION END (SETS) ##### to indicate the part of the file that should be replaced with the set declaration! | 
set declaration in GAMS syntax
Jan Philipp Dietrich, Florian Humpenöder
countries <- c("DEU", "FRA", "ENG", "ITA", "NLD", "POL")
map <- data.frame(region = rep(c("REG1","REG2"), 3), countries = countries)
sets <- list(list(name  = "countries", 
                  desc  = "list of countries", 
                  items = countries),
             list(name = "country2region",
                  desc = "mapping between countries and regions",
                  items = map))
 cat(writeSets(sets), sep="\n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.