saveDatasheet | R Documentation |
Saves Datasheets to a SsimLibrary
, Project
, or
Scenario
.
saveDatasheet( ssimObject, data, name = NULL, fileData = NULL, append = NULL, forceElements = FALSE, force = FALSE, breakpoint = FALSE, import = TRUE, path = NULL ) ## S4 method for signature 'character' saveDatasheet( ssimObject, data, name = NULL, fileData = NULL, append = NULL, forceElements = FALSE, force = FALSE, breakpoint = FALSE, import = TRUE, path = NULL ) ## S4 method for signature 'SsimObject' saveDatasheet( ssimObject, data, name = NULL, fileData = NULL, append = NULL, forceElements = FALSE, force = FALSE, breakpoint = FALSE, import = TRUE, path = NULL )
ssimObject |
|
data |
data.frame, named vector, or list of these. One or more Datasheets to load |
name |
character or vector of these. The name(s) of the Datasheet(s) to
be saved. If a vector of names is provided, then a list must be provided
for the |
fileData |
named list or raster stack. Names are file names (without paths),
corresponding to entries in |
append |
logical. If |
forceElements |
logical. If |
force |
logical. If Datasheet scope is Project/SsimLibrary, and |
breakpoint |
logical. Set to |
import |
logical. Set to |
path |
character. output path (optional) |
SsimObject/Project/Scenario should identify a single SsimObject.
If fileData != NULL
, each element of names(fileData)
should correspond uniquely
to at most one entry in data. If a name is not found in data the element will
be ignored with a warning. If names(fileData)
are full filepaths, rsyncrosim
will write each object to the corresponding path for subsequent loading by SyncroSim.
Note this is generally more time-consuming because the files must be written twice.
If names(fileData)
are not filepaths (faster, recommended), rsyncrosim will
write each element directly to the appropriate SyncroSim input/output folders.
rsyncrosim will write each element of fileData directly to the appropriate
SyncroSim input/output folders. If fileData != NULL
, data should be a data.frame,
vector, or list of length 1, not a list of length >1.
About the 'append' argument:
A Datasheet is a VALIDATION SOURCE if its data can be used to validate column values in a different Datasheet.
The append
argument will be ignored if the Datasheet is a validation
source and has a Project scope. In this case the data will be MERGED.
Invisibly returns a vector or list of logical values for each
input: TRUE
upon success (i.e.successful save) and FALSE
upon failure.
# Install helloworldSpatial package addPackage("helloworldSpatial") # Set the file path and name of the new SsimLibrary myLibraryName <- file.path(tempdir(),"testlib_saveDatasheet") # Set the SyncroSim Session, SsimLibrary, Project, and Scenario mySession <- session() myLibrary <- ssimLibrary(name = myLibraryName, session = mySession, package = "helloworldSpatial", template = "example-library") myProject <- project(myLibrary, project = "Definitions") myScenario <- scenario(myProject, scenario = "My Scenario") # Get all Datasheet info myDatasheets <- datasheet(myScenario) # Get a specific Datasheet myDatasheet <- datasheet(myScenario, name = "RunControl") # Modify Datasheet myDatasheet$MaximumTimestep <- 10 # Save Datasheet saveDatasheet(ssimObject = myScenario, data = myDatasheet, name = "RunControl") # Import data after saving saveDatasheet(ssimObject = myScenario, data = myDatasheet, name = "RunControl", import = TRUE) # Save the new Datasheet to a specified output path saveDatasheet(ssimObject = myScenario, data = myDatasheet, name = "RunControl", path = tempdir()) # Save a raster stack using fileData # Create a raster stack - add as many raster files as you want here map1 <- datasheetRaster(myScenario, datasheet = "InputDatasheet", column = "InterceptRasterFile") inRasters <- raster::stack(map1) # Change the name of the rasters in the input Datasheets to match the stack inSheet <- datasheet(myScenario, name="InputDatasheet") inSheet[1,"InterceptRasterFile"] <- names(inRasters)[1] # Save the raster stack to the input Datasheet saveDatasheet(myScenario, data=inSheet, name="InputDatasheet", fileData=inRasters)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.