| Title: | An Interface Between the 'FSKX' Standard and 'R' |
|---|---|
| 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. |
| Authors: | Alberto Garre [aut, cre], Miguel de Alba Aparicio [aut], Thomas Schueler [aut], Pablo S. Fernandez [aut], Matthias Filter [aut] |
| Maintainer: | Alberto Garre <[email protected]> |
| License: | GPL-3 |
| Version: | 0.2.0 |
| Built: | 2026-05-09 07:32:56 UTC |
| Source: | https://github.com/cran/FSK2R |
Checks that the files defined in the manifest exist
check_manifest_files(my_manifest, file_dir)check_manifest_files(my_manifest, file_dir)
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
clean_empty_values(obj)clean_empty_values(obj)
obj |
Object to clean (any R object - list, vector, etc.) |
Cleaned object with empty values removed
Clean empty values from JSON string
clean_json_string(json_string)clean_json_string(json_string)
json_string |
JSON string to clean |
Cleaned JSON string with empty arrays and null values removed
Fix the metadat so that it is lists
convert_metadata_to_lists(my_metadata)convert_metadata_to_lists(my_metadata)
my_metadata |
A list with the information in the GoogleSheet as generated by metadata_list_to_fsk. |
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.
create_fsk( r_model, r_visualization = NULL, readme = NULL, other_files = NULL, pckg_frame = NULL )create_fsk( r_model, r_visualization = NULL, readme = NULL, other_files = NULL, pckg_frame = NULL )
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. |
An instance of FSK2R.
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)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)
This function is needed to convert the output format of rjson to the one used by FSK2R.
dataframe_to_list(this_frame)dataframe_to_list(this_frame)
this_frame |
data.frame to convert to a list. |
Exports an object of FSK class as an .fskx file
export_fsk(fsk_object, out_path, check = TRUE)export_fsk(fsk_object, out_path, check = TRUE)
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. |
None
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"))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
export_manifest(fsk_object, out_path, check = FALSE)export_manifest(fsk_object, out_path, check = FALSE)
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
export_metadata(fsk_object, out_path, check = FALSE)export_metadata(fsk_object, out_path, check = FALSE)
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
export_modelmetadata(fsk_object, out_path, check = FALSE)export_modelmetadata(fsk_object, out_path, check = FALSE)
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
export_otherfiles(fsk_object, out_path, check = FALSE)export_otherfiles(fsk_object, out_path, check = FALSE)
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
export_packages(fsk_object, out_path, check = FALSE)export_packages(fsk_object, out_path, check = FALSE)
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 R model of an FSK2R object
export_R_model(fsk_object, out_path, check = FALSE)export_R_model(fsk_object, out_path, check = FALSE)
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
export_readme(fsk_object, out_path, check = FALSE)export_readme(fsk_object, out_path, check = FALSE)
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
export_sbmlModel(fsk_object, out_path, check = FALSE)export_sbmlModel(fsk_object, out_path, check = FALSE)
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
export_simulation(fsk_object, out_path, check = FALSE)export_simulation(fsk_object, out_path, check = FALSE)
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
export_visualization(fsk_object, out_path, check = FALSE)export_visualization(fsk_object, out_path, check = FALSE)
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 simulation environment variables as workspace.r file and workspace.RData for easy loading in R sessions.
export_workspace(fsk_object, out_path, check = FALSE, simulation_env = NULL)export_workspace(fsk_object, out_path, check = FALSE, simulation_env = NULL)
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) |
This function parses the metadata.rdf to find the actual filenames for model scripts and visualization scripts, rather than assuming standard names.
extract_script_filenames_from_rdf(rdf_metadata)extract_script_filenames_from_rdf(rdf_metadata)
rdf_metadata |
The parsed RDF metadata from read_fsk_rdf_metadata |
A list with modelScript and visualizationScript filenames
Finds where packages are stored
find_packages(pckgs)find_packages(pckgs)
pckgs |
Character vector with packages names |
A list of packages locations. If one is not present, a character(0).
Starts FSK runner within RStudio.
FSK_runner()FSK_runner()
None
Author Information
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 )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 )
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
FSKDataBackground( study = NULL, studySample = NULL, dietaryAssessmentMethod = NULL, laboratory = NULL, assay = NULL )FSKDataBackground( study = NULL, studySample = NULL, dietaryAssessmentMethod = NULL, laboratory = NULL, assay = NULL )
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
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 )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 )
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) |
S3 classes for FSK metadata based on the FSKX JSON schema specification. These classes ensure proper JSON serialization with correct array/scalar types.
FSKMetadata( modelType = "genericModel", generalInformation = NULL, scope = NULL, dataBackground = NULL, modelMath = NULL )FSKMetadata( modelType = "genericModel", generalInformation = NULL, scope = NULL, dataBackground = NULL, modelMath = NULL )
modelType |
Model type, default "genericModel" |
generalInformation |
FSKGeneralInformation object |
scope |
FSKScope object |
dataBackground |
FSKDataBackground object |
modelMath |
FSKModelMath object |
Model Category Information
FSKModelCategory( modelClass = NULL, modelSubClass = NULL, modelClassComment = NULL, basicProcess = NULL )FSKModelCategory( modelClass = NULL, modelSubClass = NULL, modelClassComment = NULL, basicProcess = NULL )
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
FSKModelMath( parameter = NULL, qualityMeasures = NULL, modelEquation = NULL, fittingProcedure = NULL, exposure = NULL, event = NULL )FSKModelMath( parameter = NULL, qualityMeasures = NULL, modelEquation = NULL, fittingProcedure = NULL, exposure = NULL, event = NULL )
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
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 )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 )
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
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 )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 )
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
FSKScope( product = NULL, hazard = NULL, populationGroup = NULL, generalComment = NULL, temporalInformation = NULL, spatialInformation = NULL )FSKScope( product = NULL, hazard = NULL, populationGroup = NULL, generalComment = NULL, temporalInformation = NULL, spatialInformation = NULL )
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) |
Returns the background of an FSK object
get_background(fsk_obj)get_background(fsk_obj)
fsk_obj |
An object of class FSK2R |
A nested list with the following entries:
studyTitle
studyDescription
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) get_background(my_fsk)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
get_general_info(fsk_obj)get_general_info(fsk_obj)
fsk_obj |
An object of class FSK2R |
A nested list with the following entries:
name
source
identifier
creationDate
rights
language
software
creators
reference
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) get_general_info(my_fsk)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
get_modelmath(fsk_obj)get_modelmath(fsk_obj)
fsk_obj |
An object of class FSK2R |
A nested list with the following entries:
parameter
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) get_modelmath(my_fsk)path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) get_modelmath(my_fsk)
Readme of an FSK object
get_readme(fsk_obj)get_readme(fsk_obj)
fsk_obj |
An object of class FSK2R |
A character vector with the text in the README file.
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) get_readme(my_fsk)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
get_scope(fsk_obj)get_scope(fsk_obj)
fsk_obj |
An object of class FSK2R |
A nested list with the following entries:
product
hazard
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) get_scope(my_fsk)path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) get_scope(my_fsk)
Extract session information
get_session_info()get_session_info()
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
get_simulations(fsk_obj)get_simulations(fsk_obj)
fsk_obj |
An object of class FSK2R |
A list of simulations, each with its parameters.
Importst the file in file_path and transforms it into a list of class FSK2R.
import_fsk(file_path, check = FALSE)import_fsk(file_path, check = FALSE)
file_path |
Path where the file is located. |
check |
Whether checks are made. FALSE by default. |
An instance of FSK2R.
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) get_general_info(my_fsk)path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) get_general_info(my_fsk)
Join nodes are not yet supported by FSK2R. It just gives an error message when called.
import_fsk_join(file_path, check = TRUE)import_fsk_join(file_path, check = TRUE)
file_path |
Path where the file is located. |
check |
Whether checks are made. FALSE by default. |
Does the object have an R model?
is_fsk_with_r(fsk_obj)is_fsk_with_r(fsk_obj)
fsk_obj |
An object of class FSK2R |
A logical vector.
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) is_fsk_with_r(my_fsk)path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) is_fsk_with_r(my_fsk)
Is it an instance of FSK2R?
is.FSK2R(object)is.FSK2R(object)
object |
Object to check |
A logical vector
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) is.FSK2R(my_fsk)path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) is.FSK2R(my_fsk)
Maps the location (range) of different pieces of data within the Excel/Google Sheets template. It also includes the names of the sheets.
map_FSK_metadata(type_of_model = "generic", fsk_version = "1.04")map_FSK_metadata(type_of_model = "generic", fsk_version = "1.04")
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. |
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.
Returns a map of the names used within the sheets of the Excel/GoogleSheets template and the ones in metadata.json.
map_metadata_xml_template()map_metadata_xml_template()
Converts the contents of the Excel/Google Sheets template into a list with the format of the FSK2R object.
metadata_list_to_fsk(my_metadata, fsk_version = "1.0.5")metadata_list_to_fsk(my_metadata, fsk_version = "1.0.5")
my_metadata |
A list generated by |
fsk_version |
Version of the FSK template. |
Number of simulations in the FSK2R object
n_simuls_fsk(fsk_obj)n_simuls_fsk(fsk_obj)
fsk_obj |
An instance of FSK2R |
An integer vector of length one.
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) n_simuls_fsk(my_fsk)path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) n_simuls_fsk(my_fsk)
Read the metadata.json file
read_fsk_json_metadata(file_dir, check = FALSE, filename = "metaData.json")read_fsk_json_metadata(file_dir, check = FALSE, filename = "metaData.json")
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). |
A list with the contents of the metadata file.
Read the manifest of an FSK file and convert it to a data.frame
read_fsk_manifest(file_dir, check = FALSE, filename = "manifest.xml")read_fsk_manifest(file_dir, check = FALSE, filename = "manifest.xml")
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). |
A data.frame with the contents of the xlm file.
FSK metadata from local Excel file
read_fsk_metadata_excel( fsk_object, path, type_of_model = "generic", fsk_version = "1.0.5" )read_fsk_metadata_excel( fsk_object, path, type_of_model = "generic", fsk_version = "1.0.5" )
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). |
A list with the information in the Excel file as generated by metadata_list_to_fsk.
Read the model.sbml
read_fsk_model(file_dir, check = FALSE, filename = "model.sbml")read_fsk_model(file_dir, check = FALSE, filename = "model.sbml")
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). |
A list with the contents of the .xml file.
Read the packages.json
read_fsk_packages(file_dir, check = FALSE, filename = "packages.json")read_fsk_packages(file_dir, check = FALSE, filename = "packages.json")
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). |
A list with the contents of the JSON file.
Read the metadata.rdf
read_fsk_rdf_metadata(file_dir, check = FALSE, filename = "metadata.rdf")read_fsk_rdf_metadata(file_dir, check = FALSE, filename = "metadata.rdf")
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). |
A list with the contents of the .xml file.
Read the README file
read_fsk_readme(file_dir, check = FALSE, filename = "README.txt")read_fsk_readme(file_dir, check = FALSE, filename = "README.txt")
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). |
A character string with the content of the README file.
Read the sim.sedml file
read_fsk_sim(file_dir, check = FALSE, filename = "sim.sedml")read_fsk_sim(file_dir, check = FALSE, filename = "sim.sedml")
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). |
A list with the content of the xml file.
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.
read_other_files(my_tempdir, my_manifest, check = FALSE, rdf_metadata = NULL)read_other_files(my_tempdir, my_manifest, check = FALSE, rdf_metadata = NULL)
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 R model in an FSK model
read_R_model(file_dir, check = FALSE, filename = "model.R")read_R_model(file_dir, check = FALSE, filename = "model.R")
file_dir |
path to the file. |
check |
Whether to make checks. FALSE by default. |
filename |
Name of the file (model.R by default). |
A character string with the contents of the R file.
Reads the visualization script in an FSK model
read_visualization(file_dir, check = FALSE, filename = "visualization.R")read_visualization(file_dir, check = FALSE, filename = "visualization.R")
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). |
A character string with the contents of the R file.
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().
run_all_simulations( fsk_object, run_visualization = FALSE, copy_workspace = FALSE, workspace_mode = "all", inject_to_global = FALSE )run_all_simulations( fsk_object, run_visualization = FALSE, copy_workspace = FALSE, workspace_mode = "all", inject_to_global = FALSE )
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. |
A named list with the results of all simulations
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.
run_simulation( fsk_object, index, run_visualization = FALSE, copy_workspace = FALSE, workspace_mode = "all", inject_to_global = FALSE )run_simulation( fsk_object, index, run_visualization = FALSE, copy_workspace = FALSE, workspace_mode = "all", inject_to_global = FALSE )
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. |
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.
Sets a new simulation using the parameters defined in simulation_pars. The method updates all the relevant methods.
set_new_simulation(fsk_object, simulation_id, parameters)set_new_simulation(fsk_object, simulation_id, parameters)
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. |
An instance of FSK2R with the additional simulation data.
Readme of an FSK object
set_readme(fsk_object, readme_text)set_readme(fsk_object, readme_text)
fsk_object |
An instance of FSK2R. |
readme_text |
A character vector of length 1 with the content of the README file. |
An instance of FSK2R.
path_example <- system.file("extdata", "ToyModelv4.fskx", package = "FSK2R") my_fsk <- import_fsk(path_example) set_readme(my_fsk, "This is the README.")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
update_manifest(fsk_object)update_manifest(fsk_object)
fsk_object |
An instance of FSK2R. |