Learn R Programming

rapsimng

rapsimng package is designed to modify and run the *.apsimx simulations using R in APSIM Next Generation.

Features

  • Find elements in the *.apsimx file

Installation

Install from CRAN.

install.packages('rapsimng')

Install the developing version from Github.

remotes::install_github('byzheng/rapsimng')

Read APSIMX file

The wheat.apsimx in the validation dataset of APSIM NG is used as an example. Function read_apsimx is used to read *.apsimx file through jsonlite::read_json and returns as a list.

# Read Wheat.apsimx file with `read_apsimx` which returns a list of json results.
file <- system.file("extdata/wheat.apsimx", package = "rapsimng")
m <- read_apsimx(file)

Search by of APSIM NG

A node in the apsimx file can be found using the path specification in APSIM NG.

potential <- search_path(m,
    path = '[Structure].BranchingRate.PotentialBranchingRate.Vegetative.PotentialBranchingRate')
potential

Modify a found model

new_model <- potential$node
new_model$XProperty <- 'NewVariable'

Replace the new model

new <- replace_model(m, potential$path, new_model)

Save into a new apsimx file

write_apsimx(new, tempfile(fileext = '.json'))

Run apsimx file

A function run_models is wrapped for APSIM NG Models.exe in the command line and can be called to run apsimx files. See APSIM website for documentation.

Copy Link

Version

Install

install.packages('rapsimng')

Monthly Downloads

233

Version

0.4.4

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Bangyou Zheng

Last Published

February 2nd, 2024

Functions in rapsimng (0.4.4)

get_metfile

Get the met file name for an experiment
read_report

Read apsimx database in db file format
get_parent

Get the parent node from a path
get_simulations

Get simulations for a factorial experiment
new_model

Create a new model
read_apsimx

Read APSIMX file
insert_model

Insert a model into apsimx
minimum_apsimng

Create the minimum requirements to run an APSIM Next Generation
available_models

List all available models in APSIM NG
list_report

List all reports in the database
append_model

append a model into apsimx
remove_model

Remove a model with new values
run_models

Run apsimx file using Models.exe
replace_model

Replace a model with new values
disable_models

Disable models in apsimx
update_cultivar

Title Update the cultivar parameters
test_apsimx

Test whether all files under published folder of apsimx are required
set_parameter_value

Set a parameter with a new value
get_cultivar

Get all cultivar parameters in a model
write_apsimx

Write APSIMX file
search_node

Find element(s) in apsimx file
keep_simulations

Keep simulations for a factorial experiment
search_path

Find a model in the apsimx file using specified path
insert_models

Insert models into apsimx