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

Crop-specific resources

For crop-specific functions and additional resources, please refer to:

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

253

Version

0.5.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Bangyou Zheng

Last Published

May 6th, 2026

Functions in rapsimng (0.5.0)

get_parent

Get the parent node from a path
search_path

Find a model in the apsimx file using specified path
new_model

Create a new model
insert_models

Insert models into apsimx
read_apsimx

Read APSIMX file
install_apsimng

Install ApsimNG Software
run_models

Run apsimx file using Models.exe
read_report

Read apsimx database in db file format
update_cultivar

Title Update the cultivar parameters
new_cultivar

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

Keep simulations for a factorial experiment
search_node

Find element(s) in apsimx file
list_report

List all reports in the database
set_parameter_value

Set a parameter with a new value
write_apsimx

Write APSIMX file
with_apsimx

Run APSIM Next Generation Simulations in a Temporary Folder
log_level

Set the log level of apsimx file
test_apsimx

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

Split an APSIMX file into separate simulations except cultivar
minimum_apsimng

Create the minimum requirements to run an APSIM Next Generation
remove_model

Remove a model with new values
replace_model

Replace a model with new values
get_simulations

Get simulations for a factorial experiment
frost_heat_damage

Frost and Heat Damage Functions
get_experiment

Get an experiment node by name
get_pawc

Estimate Plant Available Water Capacity (PAWC) from an apsimx file
get_cultivar

Get all cultivar parameters in a model
get_metfile

Get the met file name for an experiment
insert_model

Insert a model into apsimx
append_model

append a model into apsimx
disable_models

Disable models in apsimx