dependency: Get, set or remove Scenario dependency(s)

Description Usage Arguments Details Value Examples

Description

List dependencies, set dependencies, or remove dependencies from a SyncroSim Scenario. Setting dependencies is a way of linking together Scenario Datafeeds, such that a change in the Scenario that is the source dependency will update the dependent Scenario as well.

Usage

1
2
3
4
5
6
7
dependency(scenario, dependency = NULL, remove = FALSE, force = FALSE)

## S4 method for signature 'character'
dependency(scenario, dependency = NULL, remove = FALSE, force = FALSE)

## S4 method for signature 'Scenario'
dependency(scenario, dependency = NULL, remove = FALSE, force = FALSE)

Arguments

scenario

Scenario object, character string, integer, or vector of these. The Scenario object, name, or ID to which a dependency is to be added (or has already been added if remove=TRUE). Note that integer ids are slightly faster

dependency

Scenario object, character string, integer, or list/vector of these. The Scenario(s) that are the source of the dependency, in order from lowest to highest precedence. If NULL (default) other arguments are ignored and the list of existing dependencies is returned

remove

logical. If FALSE (default) dependencies are added. If TRUE, dependencies are removed

force

logical. If FALSE (default) prompt before removing dependencies

Details

If dependency==NULL, other arguments are ignored, and set of existing dependencies is returned in order of precedence (from highest to lowest precedence). Otherwise, returns list of saved or error messages for each dependency of each scenario.

Note that the order of dependencies can be important - dependencies added most recently take precedence over existing dependencies. So, dependencies included in the dependency argument take precedence over any other existing dependencies. If the dependency argument includes more than one element, elements are ordered from lowest to highest precedence.

Value

If dependency is NULL, a data frame of existing dependencies, or list of these if multiple inputs are provided. If dependency is not NULL, the function invisibly returns a list bearing the names of the dependencies inputted and carrying a logical TRUE upon success (i.e.successful addition or deletion) and FALSE upon failure

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Specify file path and name of new SsimLibrary
myLibraryName <- file.path(tempdir(), "testlib")

# Set up a SyncroSim Session, SsimLibrary, Project, and 2 Scenarios
mySession <- session()
myLibrary <- ssimLibrary(name = myLibraryName, session = mySession)
myProject <- project(myLibrary, project = "Definitions")
myScenario <- scenario(myProject, scenario = "My Scenario")
myNewScenario <- scenario(myProject,
                          scenario = "my New Scenario")

# Set myScenario as a dependency of myNewScenario
dependency(myNewScenario, dependency = myScenario)

# Get all dependencies info
dependency(myNewScenario)

# Remove dependency
dependency(myNewScenario, dependency = myScenario, remove = TRUE)

# Force removal of dependency
dependency(myNewScenario, dependency = myScenario, remove = TRUE,
           force = TRUE)

rsyncrosim documentation built on Oct. 28, 2021, 1:07 a.m.