Type: | Package |
Title: | An Interface Between the 'FSKX' Standard and 'R' |
Version: | 0.2.0 |
Description: | Functions for importing, creating, editing and exporting 'FSK' files https://foodrisklabs.bfr.bund.de/fskx-food-safety-knowledge-exchange-format/ using the 'R' programming environment. Furthermore, it enables users to run simulations contained in the 'FSK' files and visualize the results. |
License: | GPL-3 |
Encoding: | UTF-8 |
Imports: | XML (≥ 3.98), purrr (≥ 0.2.4), dplyr (≥ 0.7.8), tibble (≥ 2.0.0), tidyr (≥ 0.7.2), rlang (≥ 0.3.0.1), readxl (≥ 1.3.1), readtext (≥ 0.7.1), xml2 (≥ 1.2.0), jsonlite (≥ 1.6.0), shiny (≥ 1.3.2), tools (≥ 3.5.3), utils (≥ 3.5.3), R.utils (≥ 2.9.0) |
Suggests: | knitr (≥ 1.9), rmarkdown (≥ 1.12), testthat |
VignetteBuilder: | knitr |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-10-10 14:50:04 UTC; alber |
Author: | Alberto Garre [aut, cre], Miguel de Alba Aparicio [aut], Thomas Schueler [aut], Pablo S. Fernandez [aut], Matthias Filter [aut] |
Maintainer: | Alberto Garre <garre.alberto@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-10-10 15:10:02 UTC |
Author Information
Description
Author Information
Usage
FSKAuthor(
title = NULL,
familyName = NULL,
givenName = NULL,
email = NULL,
telephone = NULL,
streetAddress = NULL,
country = NULL,
zipCode = NULL,
region = NULL,
timeZone = NULL,
gender = NULL,
note = NULL,
organization = NULL
)
FSKCreator(
title = NULL,
familyName = NULL,
givenName = NULL,
email = NULL,
telephone = NULL,
streetAddress = NULL,
country = NULL,
zipCode = NULL,
region = NULL,
timeZone = NULL,
gender = NULL,
note = NULL,
organization = NULL
)
Arguments
title |
Title (string) |
familyName |
Family name (string) |
givenName |
Given name (string) |
email |
Email address (string, required) |
telephone |
Telephone (string) |
streetAddress |
Street address (string) |
country |
Country (string) |
zipCode |
Zip code (string) |
region |
Region (string) |
timeZone |
Time zone (string) |
gender |
Gender (string) |
note |
Note (string) |
organization |
Organization (string) |
Data Background Section
Description
Data Background Section
Usage
FSKDataBackground(
study = NULL,
studySample = NULL,
dietaryAssessmentMethod = NULL,
laboratory = NULL,
assay = NULL
)
Arguments
study |
FSKStudy object |
studySample |
List of FSKStudySample objects (array) |
dietaryAssessmentMethod |
List of FSKDietaryAssessmentMethod objects (array) |
laboratory |
List of FSKLaboratory objects (array) |
assay |
List of FSKAssay objects (array) |
General Information Section
Description
General Information Section
Usage
FSKGeneralInformation(
name = NULL,
source = NULL,
identifier = NULL,
author = NULL,
creator = NULL,
creationDate = NULL,
modificationDate = NULL,
rights = NULL,
availability = NULL,
url = NULL,
format = NULL,
reference = NULL,
language = NULL,
software = NULL,
languageWrittenIn = NULL,
modelCategory = NULL,
status = NULL,
objective = NULL,
description = NULL
)
Arguments
name |
Model name (string) |
source |
Source of model/data (string) |
identifier |
Unique identifier (string) |
author |
List of FSKAuthor objects (array) |
creator |
List of FSKCreator objects (array) |
creationDate |
Creation date (string) |
modificationDate |
Modification dates (array of strings) |
rights |
Rights information (string) |
availability |
Availability (string) |
url |
URL (string) |
format |
Format (string) |
reference |
List of FSKReference objects (array) |
language |
Language (string) |
software |
Software (string) |
languageWrittenIn |
Language written in (string) |
modelCategory |
FSKModelCategory object |
status |
Status (string) |
objective |
Objective (string) |
description |
Description (string) |
FSK Metadata Classes
Description
S3 classes for FSK metadata based on the FSKX JSON schema specification. These classes ensure proper JSON serialization with correct array/scalar types.
Usage
FSKMetadata(
modelType = "genericModel",
generalInformation = NULL,
scope = NULL,
dataBackground = NULL,
modelMath = NULL
)
Arguments
modelType |
Model type, default "genericModel" |
generalInformation |
FSKGeneralInformation object |
scope |
FSKScope object |
dataBackground |
FSKDataBackground object |
modelMath |
FSKModelMath object |
Model Category Information
Description
Model Category Information
Usage
FSKModelCategory(
modelClass = NULL,
modelSubClass = NULL,
modelClassComment = NULL,
basicProcess = NULL
)
Arguments
modelClass |
Model class (string, required) |
modelSubClass |
Model subclass (array of strings) |
modelClassComment |
Model class comment (string) |
basicProcess |
Basic process (array of strings) |
Model Math Section
Description
Model Math Section
Usage
FSKModelMath(
parameter = NULL,
qualityMeasures = NULL,
modelEquation = NULL,
fittingProcedure = NULL,
exposure = NULL,
event = NULL
)
Arguments
parameter |
List of FSKParameter objects (array) |
qualityMeasures |
List of FSKQualityMeasures objects (array) |
modelEquation |
List of FSKModelEquation objects (array) |
fittingProcedure |
Fitting procedure (string) |
exposure |
List of FSKExposure objects (array) |
event |
Event information (array of strings) |
Parameter Information
Description
Parameter Information
Usage
FSKParameter(
id = NULL,
classification = NULL,
name = NULL,
description = NULL,
unit = NULL,
unitCategory = NULL,
dataType = NULL,
source = NULL,
subject = NULL,
distribution = NULL,
value = NULL,
reference = NULL,
variabilitySubject = NULL,
minValue = NULL,
maxValue = NULL,
error = NULL
)
Arguments
id |
Parameter ID (string, required) |
classification |
Classification (string, required) |
name |
Parameter name (string, required) |
description |
Description (string) |
unit |
Unit (string, required) |
unitCategory |
Unit category (string) |
dataType |
Data type (string, required) |
source |
Source (string) |
subject |
Subject (string) |
distribution |
Distribution (string) |
value |
Value (string) |
reference |
FSKReference object |
variabilitySubject |
Variability subject (string) |
minValue |
Minimum value (string) |
maxValue |
Maximum value (string) |
error |
Error (string) |
Reference Information
Description
Reference Information
Usage
FSKReference(
isReferenceDescription = NULL,
title = NULL,
doi = NULL,
publicationType = NULL,
date = NULL,
pmid = NULL,
authorList = NULL,
abstract = NULL,
journal = NULL,
volume = NULL,
issue = NULL,
status = NULL,
website = NULL,
comment = NULL
)
Arguments
isReferenceDescription |
Is reference description (boolean) |
title |
Title (string, required) |
doi |
DOI (string, required) |
publicationType |
Publication type (string) |
date |
Date (string) |
pmid |
PubMed ID (string) |
authorList |
Author list (string) |
abstract |
Abstract (string) |
journal |
Journal (string) |
volume |
Volume (string) |
issue |
Issue (string) |
status |
Status (string) |
website |
Website (string) |
comment |
Comment (string) |
Scope Section
Description
Scope Section
Usage
FSKScope(
product = NULL,
hazard = NULL,
populationGroup = NULL,
generalComment = NULL,
temporalInformation = NULL,
spatialInformation = NULL
)
Arguments
product |
List of FSKProduct objects (array) |
hazard |
List of FSKHazard objects (array) |
populationGroup |
List of FSKPopulationGroup objects (array) |
generalComment |
General comment (string) |
temporalInformation |
Temporal information (string) |
spatialInformation |
Spatial information (array of strings) |
Startup FSK runner
Description
Starts FSK runner within RStudio.
Usage
FSK_runner()
Value
None
Checks that the files defined in the manifest exist
Description
Checks that the files defined in the manifest exist
Usage
check_manifest_files(my_manifest, file_dir)
Arguments
my_manifest |
A list with the contents of the manifest file. |
file_dir |
Path to the directory where all the files have been extracted. |
Recursively clean object by removing empty values
Description
Recursively clean object by removing empty values
Usage
clean_empty_values(obj)
Arguments
obj |
Object to clean (any R object - list, vector, etc.) |
Value
Cleaned object with empty values removed
Clean empty values from JSON string
Description
Clean empty values from JSON string
Usage
clean_json_string(json_string)
Arguments
json_string |
JSON string to clean |
Value
Cleaned JSON string with empty arrays and null values removed
Fix the metadat so that it is lists
Description
Fix the metadat so that it is lists
Usage
convert_metadata_to_lists(my_metadata)
Arguments
my_metadata |
A list with the information in the GoogleSheet as generated by metadata_list_to_fsk. |
Creates an FSK model from an existing R script
Description
The model includes the R model. If provided as arguments, it also includes the visualization script and the README. Besides, it generates a typical model_metadata, as well as a simulation (without parameters). The manifest is left empty.
Usage
create_fsk(
r_model,
r_visualization = NULL,
readme = NULL,
other_files = NULL,
pckg_frame = NULL
)
Arguments
r_model |
character with the path to the R script with the model. |
r_visualization |
(optional) character with the path to the R script with the visualization. |
readme |
(optional) path to README file. |
other_files |
(optional) character vector with the path to additional files required by the model. |
pckg_frame |
(optional) data.frame with 2 columns 'Package' and 'Version' with the packages used by the model. |
Value
An instance of FSK2R.
Examples
model_path <- system.file("extdata", "model.r", package = "FSK2R")
visualization_path <- system.file("extdata", "visualization.r", package = "FSK2R")
FSK_from_R <- create_fsk(model_path, visualization_path)
Converts a dataframe to a list
Description
This function is needed to convert the output format of rjson to the one used by FSK2R.
Usage
dataframe_to_list(this_frame)
Arguments
this_frame |
data.frame to convert to a list. |
Functions for exporting the R model of an FSK2R object
Description
Functions for exporting the R model of an FSK2R object
Usage
export_R_model(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Exports an object of FSK class as an .fskx file
Description
Exports an object of FSK class as an .fskx file
Usage
export_fsk(fsk_object, out_path, check = TRUE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Value
None
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
class(my_fsk)
export_fsk(my_fsk, out_path=file.path(tempdir(), "out.fskx"))
Functions for exporting the manifest of an FSK2R object
Description
Functions for exporting the manifest of an FSK2R object
Usage
export_manifest(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Function for exporting the metadata of an FSK2R object
Description
Function for exporting the metadata of an FSK2R object
Usage
export_metadata(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Functions for exporting the model metadata of an FSK2R object
Description
Functions for exporting the model metadata of an FSK2R object
Usage
export_modelmetadata(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Export other files
Description
Export other files
Usage
export_otherfiles(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Functions for exporting the packages of an FSK2R object
Description
Functions for exporting the packages of an FSK2R object
Usage
export_packages(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Functions for exporting the README of an FSK2R object
Description
Functions for exporting the README of an FSK2R object
Usage
export_readme(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Export the model.sbml
Description
Export the model.sbml
Usage
export_sbmlModel(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Export the sim.sedml
Description
Export the sim.sedml
Usage
export_simulation(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Functions for exporting the visualization script of an FSK2R object
Description
Functions for exporting the visualization script of an FSK2R object
Usage
export_visualization(fsk_object, out_path, check = FALSE)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
Functions for exporting the workspace of an FSK2R object
Description
Exports simulation environment variables as workspace.r file and workspace.RData for easy loading in R sessions.
Usage
export_workspace(fsk_object, out_path, check = FALSE, simulation_env = NULL)
Arguments
fsk_object |
The instance of FSK2R to be exported. |
out_path |
Path where the file is to be saved. |
check |
Whether checks are made. TRUE by default. |
simulation_env |
Environment containing simulation results (optional) |
Extract script filenames from RDF metadata
Description
This function parses the metadata.rdf to find the actual filenames for model scripts and visualization scripts, rather than assuming standard names.
Usage
extract_script_filenames_from_rdf(rdf_metadata)
Arguments
rdf_metadata |
The parsed RDF metadata from read_fsk_rdf_metadata |
Value
A list with modelScript and visualizationScript filenames
Finds where packages are stored
Description
Finds where packages are stored
Usage
find_packages(pckgs)
Arguments
pckgs |
Character vector with packages names |
Value
A list of packages locations. If one is not present, a character(0).
Returns the background of an FSK object
Description
Returns the background of an FSK object
Usage
get_background(fsk_obj)
Arguments
fsk_obj |
An object of class FSK2R |
Value
A nested list with the following entries:
studyTitle
studyDescription
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
get_background(my_fsk)
Returns the general info of an FSK object
Description
Returns the general info of an FSK object
Usage
get_general_info(fsk_obj)
Arguments
fsk_obj |
An object of class FSK2R |
Value
A nested list with the following entries:
name
source
identifier
creationDate
rights
language
software
creators
reference
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
get_general_info(my_fsk)
Returns the model math of an FSK object
Description
Returns the model math of an FSK object
Usage
get_modelmath(fsk_obj)
Arguments
fsk_obj |
An object of class FSK2R |
Value
A nested list with the following entries:
parameter
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
get_modelmath(my_fsk)
Readme of an FSK object
Description
Readme of an FSK object
Usage
get_readme(fsk_obj)
Arguments
fsk_obj |
An object of class FSK2R |
Value
A character vector with the text in the README file.
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
get_readme(my_fsk)
Returns the scope of an FSK object
Description
Returns the scope of an FSK object
Usage
get_scope(fsk_obj)
Arguments
fsk_obj |
An object of class FSK2R |
Value
A nested list with the following entries:
product
hazard
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
get_scope(my_fsk)
Extract session information
Description
Extract session information
Usage
get_session_info()
Value
A list with 3 elements: r_version, platform and pckgs. The latter is a data.frame with two columns: package and version.
Returns a summary of the simulations of an FSK object
Description
Returns a summary of the simulations of an FSK object
Usage
get_simulations(fsk_obj)
Arguments
fsk_obj |
An object of class FSK2R |
Value
A list of simulations, each with its parameters.
Import an FSK model into R
Description
Importst the file in file_path and transforms it into a list of class FSK2R.
Usage
import_fsk(file_path, check = FALSE)
Arguments
file_path |
Path where the file is located. |
check |
Whether checks are made. FALSE by default. |
Value
An instance of FSK2R.
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
get_general_info(my_fsk)
Import of FSK with join node
Description
Join nodes are not yet supported by FSK2R. It just gives an error message when called.
Usage
import_fsk_join(file_path, check = TRUE)
Arguments
file_path |
Path where the file is located. |
check |
Whether checks are made. FALSE by default. |
Is it an instance of FSK2R?
Description
Is it an instance of FSK2R?
Usage
is.FSK2R(object)
Arguments
object |
Object to check |
Value
A logical vector
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
is.FSK2R(my_fsk)
Does the object have an R model?
Description
Does the object have an R model?
Usage
is_fsk_with_r(fsk_obj)
Arguments
fsk_obj |
An object of class FSK2R |
Value
A logical vector.
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
is_fsk_with_r(my_fsk)
Map for the contents of the metadata
Description
Maps the location (range) of different pieces of data within the Excel/Google Sheets template. It also includes the names of the sheets.
Usage
map_FSK_metadata(type_of_model = "generic", fsk_version = "1.04")
Arguments
type_of_model |
Type of model, as defined in the FSK-ML documentation. By default, 'generic'. |
fsk_version |
Character stating the version of FSK-ML. |
Value
A list with two components: the 'range' where each piece of information is stored and 'ws_name' with the name of the relevant sheet in the GoogleSheet template.
Map between the names used in the template and the xml
Description
Returns a map of the names used within the sheets of the Excel/GoogleSheets template and the ones in metadata.json.
Usage
map_metadata_xml_template()
From read_fsk_metadata_XX to FSK2R format
Description
Converts the contents of the Excel/Google Sheets template into a list with the format of the FSK2R object.
Usage
metadata_list_to_fsk(my_metadata, fsk_version = "1.0.5")
Arguments
my_metadata |
A list generated by |
fsk_version |
Version of the FSK template. |
Number of simulations in the FSK2R object
Description
Number of simulations in the FSK2R object
Usage
n_simuls_fsk(fsk_obj)
Arguments
fsk_obj |
An instance of FSK2R |
Value
An integer vector of length one.
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
n_simuls_fsk(my_fsk)
Reads the R model in an FSK model
Description
Reads the R model in an FSK model
Usage
read_R_model(file_dir, check = FALSE, filename = "model.R")
Arguments
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file (model.R by default). |
Value
A character string with the contents of the R file.
Read the metadata.json file
Description
Read the metadata.json file
Usage
read_fsk_json_metadata(file_dir, check = FALSE, filename = "metaData.json")
Arguments
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file whith the information (meataData.json by default). |
Value
A list with the contents of the metadata file.
Read the manifest of an FSK file and convert it to a data.frame
Description
Read the manifest of an FSK file and convert it to a data.frame
Usage
read_fsk_manifest(file_dir, check = FALSE, filename = "manifest.xml")
Arguments
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file whith the information (manifest.xml by default). |
Value
A data.frame with the contents of the xlm file.
FSK metadata from local Excel file
Description
FSK metadata from local Excel file
Usage
read_fsk_metadata_excel(
fsk_object,
path,
type_of_model = "generic",
fsk_version = "1.0.5"
)
Arguments
fsk_object |
FSK2R object where to save the data |
path |
character describing the path to the file |
type_of_model |
character identifying the type of model |
fsk_version |
Character describing the version of FSK-ML ("1.04" by default). |
Value
A list with the information in the Excel file as generated by metadata_list_to_fsk.
Read the model.sbml
Description
Read the model.sbml
Usage
read_fsk_model(file_dir, check = FALSE, filename = "model.sbml")
Arguments
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file whith the information (model.sbml by default). |
Value
A list with the contents of the .xml file.
Read the packages.json
Description
Read the packages.json
Usage
read_fsk_packages(file_dir, check = FALSE, filename = "packages.json")
Arguments
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file whith the information (packages.json by default). |
Value
A list with the contents of the JSON file.
Read the metadata.rdf
Description
Read the metadata.rdf
Usage
read_fsk_rdf_metadata(file_dir, check = FALSE, filename = "metadata.rdf")
Arguments
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file whith the information (metadata.rdf by default). |
Value
A list with the contents of the .xml file.
Read the README file
Description
Read the README file
Usage
read_fsk_readme(file_dir, check = FALSE, filename = "README.txt")
Arguments
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file whith the information (README.txt by default). |
Value
A character string with the content of the README file.
Read the sim.sedml file
Description
Read the sim.sedml file
Usage
read_fsk_sim(file_dir, check = FALSE, filename = "sim.sedml")
Arguments
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file whith the information (sim.sedml by default). |
Value
A list with the content of the xml file.
Read "other files"
Description
The R models may require further files that we can not predict. This functions just reads all the "unrecognized" files included in the manifest and copies them to the working directory.
Usage
read_other_files(my_tempdir, my_manifest, check = FALSE, rdf_metadata = NULL)
Arguments
my_tempdir |
Temporary directory to extract contents of the zyp file. |
my_manifest |
A list with the information in the manifest file |
check |
Whether checks are made. |
rdf_metadata |
Optional list with RDF metadata used to determine script filenames and related metadata for ancillary files. Default NULL. |
Reads the visualization script in an FSK model
Description
Reads the visualization script in an FSK model
Usage
read_visualization(file_dir, check = FALSE, filename = "visualization.R")
Arguments
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file whith the information (visualization.R by default). |
Value
A character string with the contents of the R file.
Run every simulation in an FSK object
Description
Runs every simulation defined in the FSK object. This includes the ones originally included in the FSK container, as well as the ones added using set_new_simulation().
Usage
run_all_simulations(
fsk_object,
run_visualization = FALSE,
copy_workspace = FALSE,
workspace_mode = "all",
inject_to_global = FALSE
)
Arguments
fsk_object |
Instance of FSK2R |
run_visualization |
Whether to call the visualization script. FALSE by default. |
copy_workspace |
Whether to copy the simulation workspace to the user's working directory. FALSE by default. |
workspace_mode |
What to copy when copy_workspace=TRUE. Options: "all" (copy everything), "generated" (copy only files created during simulation), "modified" (copy only files modified during simulation). Default is "all". |
inject_to_global |
Whether to inject simulation variables into the user's global environment for seamless model chaining. FALSE by default for backward compatibility. |
Value
A named list with the results of all simulations
Run one simulation in an FSK object
Description
Runs the simulation corresponding to index. If defined, it also calls any visualization script. Returns all user-created variables from the simulation environment, supporting various data types including scalars, vectors, data frames, lists, and matrices.
Usage
run_simulation(
fsk_object,
index,
run_visualization = FALSE,
copy_workspace = FALSE,
workspace_mode = "all",
inject_to_global = FALSE
)
Arguments
fsk_object |
Instance of FSK2R |
index |
Index of the simulation |
run_visualization |
Whether to call the visualization script. FALSE by default. |
copy_workspace |
Whether to copy the simulation workspace to the user's working directory. FALSE by default. |
workspace_mode |
What to copy when copy_workspace=TRUE. Options: "all" (copy everything), "generated" (copy only files created during simulation), "modified" (copy only files modified during simulation). Default is "all". |
inject_to_global |
Whether to inject simulation variables into the user's global environment for seamless model chaining. FALSE by default for backward compatibility. |
Value
A named list containing all variables created by the simulation model. Each element preserves the original data type (numbers, strings, data frames, lists, matrices, etc.). Returns an empty list if no variables are created. When inject_to_global=TRUE, variables are also available in the global environment.
Define a new simulation in an FSK2R object
Description
Sets a new simulation using the parameters defined in simulation_pars. The method updates all the relevant methods.
Usage
set_new_simulation(fsk_object, simulation_id, parameters)
Arguments
fsk_object |
Instance of FSK2R |
simulation_id |
A character with an id for the new simulation. |
parameters |
A list whose names are the parameters to modify and their values their values for the simulation. |
Value
An instance of FSK2R with the additional simulation data.
Readme of an FSK object
Description
Readme of an FSK object
Usage
set_readme(fsk_object, readme_text)
Arguments
fsk_object |
An instance of FSK2R. |
readme_text |
A character vector of length 1 with the content of the README file. |
Value
An instance of FSK2R.
Examples
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R")
my_fsk <- import_fsk(path_example)
set_readme(my_fsk, "This is the README.")
Updates the manifest file
Description
Updates the manifest file
Usage
update_manifest(fsk_object)
Arguments
fsk_object |
An instance of FSK2R. |