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.
dependency(scenario, dependency = NULL, remove = FALSE, force = FALSE)
# S4 method for character
dependency(scenario, dependency = NULL, remove = FALSE, force = FALSE)
# S4 method for Scenario
dependency(scenario, dependency = NULL, remove = FALSE, force = FALSE)
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
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
logical. If FALSE
(default) dependencies are added. If TRUE
,
dependencies are removed
logical. If FALSE
(default) prompt before removing dependencies
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
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.
# \donttest{
# 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)
#> Dependency: <My Scenario [1]>, added to scenario: <my New Scenario [2]>
# Get all dependencies info
dependency(myNewScenario)
#> ScenarioID name priority
#> 1 1 My Scenario 1
# Remove dependency
dependency(myNewScenario, dependency = myScenario, remove = TRUE)
#> Do you really want to remove dependency My Scenario [1] from my New Scenario [2]? (y/n):
#> Deletion of dependency My Scenario [1] skipped
# Force removal of dependency
dependency(myNewScenario, dependency = myScenario, remove = TRUE,
force = TRUE)
#> Dependency: <My Scenario [1]>, deleted from scenario: <my New Scenario [2]>
# }