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

347

Version

0.4.5

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Bangyou Zheng

Last Published

September 23rd, 2025

Functions in rapsimng (0.4.5)

set_parameter_value

Set a parameter with a new value
write_apsimx

Write APSIMX file
update_cultivar

Title Update the cultivar parameters
with_apsimx

Run APSIM Next Generation Simulations in a Temporary Folder
search_path

Find a model in the apsimx file using specified path
read_apsimx

Read APSIMX file
search_node

Find element(s) in apsimx file
test_apsimx

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

Create a new model
insert_models

Insert models into apsimx
keep_simulations

Keep simulations for a factorial experiment
get_metfile

Get the met file name for an experiment
get_parent

Get the parent node from a path
insert_model

Insert a model into apsimx
get_simulations

Get simulations for a factorial experiment
remove_model

Remove a model with new values
read_report

Read apsimx database in db file format
available_models

List all available models in APSIM NG
append_model

append a model into apsimx
list_report

List all reports in the database
log_level

Set the log level of apsimx file
disable_models

Disable models in apsimx
get_cultivar

Get all cultivar parameters in a model
run_models

Run apsimx file using Models.exe
new_cultivar

Generate new cultivars with parameter which can be used in Replacements
replace_model

Replace a model with new values
minimum_apsimng

Create the minimum requirements to run an APSIM Next Generation