Learn R Programming

apsimr (version 1.2)

apsim: Run APSIM Simulations from R

Description

This function will run one or many APSIM simulations and read the output into R in the form of a list of data frames. If the simulation does not run for some reason then an error is returned.

Usage

apsim(exe, wd = getwd(), files = NULL)

Arguments

exe
path to the APSIM executable
wd
working directory containing the .apsim files to be run; defaults to the current working directory
files
.apsim files to be run; if left empty all .apsim files in wd will be run

Value

list of output files; each element of the list corresponds to an output file specified by the .apsim files executed

Details

The only required input is the path to the APSIM executable (APSIM.exe) usually found in the "Model" subfolder of the APSIM installation. By default, it is assumed the current working directory contains the .apsim file(s) to be run. If that is not the case then the directory containing the .apsim file(s) to be run should be specified by the wd argument. One can specify a list of .apsim files to be run within the directory wd using the files argument. If the files argument is left blank then all .apsim files within the directory specified by wd are run. The results for each .apsim file is saved as a data frame which are complied into a list. Each element of the list is of the class "apsim", which has its own print and plot routines.

Examples

Run this code
## Not run: 
# apsimExe <-"C:/Program Files (x86)/Apsim75-r3008/Model/Apsim.exe"
# apsimWd <- "~/APSIM"
# toRun <- c("Centro.apsim", "Continuous Wheat.apsim")
# results <- apsim(exe = apsimExe, wd = apsimWd, files = toRun)
# results
# plot(results$Centro)
# ## End(Not run)

Run the code above in your browser using DataLab