insert_models: Insert models into apsimx

Description Usage Arguments Value Examples

View source: R/modify.R

Description

Insert models into apsimx

Usage

1
insert_models(l, path, models)

Arguments

l

the list of apsimx file

path

If numeric, the path returned by search_path or search_node. If character, the path supported by apsimx

models

New models

Value

The modified list with new value

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
wheat <- read_apsimx(system.file("wheat.apsimx", package = "rapsimng"))
replacements <- new_model("Core.Replacements")
wheat_new <- insert_model(wheat, 1, replacements)
replacements_node <- search_path(wheat_new, ".Simulations.Replacements")
replacements_node$path
# Add a cultivar folder under replacements
cultivar_folder <- new_model("PMF.CultivarFolder", "Cultivars")
wheat_new <- insert_model(wheat_new, replacements_node$path, cultivar_folder)
cultivar_folder_node <- search_path(wheat_new,
                                    ".Simulations.Replacements.Cultivars")
cultivar_folder_node$path
# Add an new cultivar
cultivar <- new_model("PMF.Cultivar", "Hartog")
wheat_new <- insert_model(wheat_new, cultivar_folder_node$path, cultivar)
cultivar_node <- search_path(wheat_new,
                             ".Simulations.Replacements.Cultivars.Hartog")
cultivar_node$path

rapsimng documentation built on Sept. 9, 2021, 9:07 a.m.