Learn R Programming

rsyncrosim (version 1.2.9)

scenario: Create or open one or more Scenarios.

Description

Create or retrieves one or more Scenarios from a library

Usage

scenario(
  ssimObject = NULL,
  scenario = NULL,
  sourceScenario = NULL,
  summary = NULL,
  results = FALSE,
  forceElements = FALSE,
  overwrite = FALSE
)

Arguments

ssimObject

SsimLibrary/Project or character. An ssimObject containing a filepath to a library, or a filepath.

scenario

Character, integer, or vector of these. Names or ids of one or more scenarios. Note integer ids are slightly faster.

sourceScenario

Character or integer. If not NULL, new scenarios will be copies of the sourceScenario.

summary

Logical. If TRUE then loads and returns the scenario(s) in a named vector/dataframe with the scenarioId, name, description, owner, dateModified, readOnly, parentID. Default is TRUE if scenario=NULL, FALSE otherwise.

results

Logical. If TRUE only return result scenarios.

forceElements

Logical. If TRUE then returns a single scenario as a named list; otherwise returns a single scenario as a Scenario object. Applies only when summary=FALSE.

overwrite

Logical. If TRUE an existing Scenario will be overwritten.

Value

A Scenario object representing a SyncroSim scenario, a list of Scenario objects, or a dataframe of scenario names and descriptions. If summary = FALSE, returns one or more Scenario objects representing SyncroSim scenarios. If summary = TRUE, returns scenario summary info.

Details

For each element of scenario:

  • If element/project/ssimObject uniquely identifies an existing scenario: Returns the existing Scenario

  • If element/project/ssimObject uniquely identifies more than one existing scenario: Error

  • If element/project/ssimObject do not identify an existing scenario or project: Error

  • If element/project/ssimObject do not identify an existing scenario and element is numeric: Error - a name is required for new scenarios. SyncroSim will automatically assign an id when a scenario is created.

  • If element/project/ssimObject do not identify an existing scenario and do identify a project, and element is a character string: Creates a new Scenario named element in the project. SyncroSim automatically assigns an id. If sourceScenario is not NULL the new scenario will be a copy of sourceScenario.

Examples

Run this code
# NOT RUN {
# Create a new scenario
temp_dir <- tempdir()
myses <- session()
myLibrary <- ssimLibrary(name = file.path(temp_dir,"testlib"), session = myses)

myProject <- project(myLibrary, project = "a project")
myScenario <- scenario(myProject, scenario = "a scenario", overwrite = TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab