https://github.com/byzheng/rapsimng
A R package for APSIM Next Generation
https://github.com/byzheng/rapsimng
apsim apsimx r
Last synced: 3 months ago
JSON representation
A R package for APSIM Next Generation
- Host: GitHub
- URL: https://github.com/byzheng/rapsimng
- Owner: byzheng
- License: other
- Created: 2019-02-21T02:57:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-12-17T01:30:25.000Z (6 months ago)
- Last Synced: 2025-02-12T07:55:28.974Z (4 months ago)
- Topics: apsim, apsimx, r
- Language: R
- Homepage: https://rapsimng.bangyou.me/
- Size: 5.7 MB
- Stars: 11
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# rapsimng
[](https://cran.r-project.org/package=rapsimng)
[](https://cran.r-project.org/package=rapsimng)
[](https://cran.r-project.org/package=rapsimng)
[](https://cran.r-project.org/package=rapsimng)[rapsimng](https://rapsimng.bangyou.me) package is designed to modify and run the *.apsimx simulations using R in [APSIM Next Generation](https://www.apsim.info/).
## Features
* Find elements in the *.apsimx file## Installation
Install from CRAN.
```r
install.packages('rapsimng')
```Install the developing version from [Github](https://github.com/byzheng/rapsimng).
```r
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.
```r
# 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.
```r
potential <- search_path(m,
path = '[Structure].BranchingRate.PotentialBranchingRate.Vegetative.PotentialBranchingRate')
potential
```## Modify a found model
```r
new_model <- potential$node
new_model$XProperty <- 'NewVariable'
```## Replace the new model
```r
new <- replace_model(m, potential$path, new_model)
```## Save into a new apsimx file
```r
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](https://apsimnextgeneration.netlify.app/) for documentation.