Learn R Programming

APSIM (version 0.8.2)

loadApsim: Read APSIM .out files.

Description

Reads APSIM .out files.

Usage

loadApsim(dir, loadAll = TRUE, ext = ".out", returnFrame = TRUE, n = 0,
  fill = FALSE, addConstants = TRUE)

Arguments

dir
The directory to search for .out files. This is not recursive.
loadAll
If TRUE will load all files in dir. If FALSE, will load a single file specified by dir.
ext
The extension to use for output files. Default is .out.
returnFrame
Return the data as a data frame or data table. Default is TRUE, FALSE returns a data table.
n
Read the first n files. Good for testing/debugging. Default is 0 (read all files found).
fill
Where the number or names of columns is not consistent across files, fill missing columns with NA. Default is FALSE which will throw an error if the columns don't match across all files.
addConstants
Add any constants (such as ApsimVersion, Title or factor levels) found as extra columns. Default is TRUE.

Details

By default, this function will read in all output files in a directory and combine them into a single data table. Setting loadAll=FALSE will read a single file. Constants in outputs will be added as data columns and output files with differing numbers of columns can also be imported although by default this will result in an error. Care should be taken when using this option as a different number of columns in output files usually means the data came from a different set of reports or simulations which may not be relevant to your analysis.

Examples

Run this code
genericLoadApsim("c:/outputs") # load everything in the outputs directory
genericLoadApsim("c:/outputs/simulation.out", loadAll=FALSE)
# load a single file (note extension is required).
genericLoadApsim("c:/outputs", returnFrame=FALSE, fill=TRUE)
  # load everything in the outputs directory, fill any missing columns and return a data table.

Run the code above in your browser using DataLab