Learn R Programming

apsimx (version 2.2)

compare_apsim: Compare two or more apsim output objects

Description

Function which allows for a simple comparison between APSIM output objects

print method for ‘out_mrg’

plotting function for compare_apsim, it requires ggplot2

Usage

compare_apsim(..., variable, index = "Date", by, labels, verbose = FALSE)

# S3 method for out_mrg print(x, ..., digits = 2)

# S3 method for out_mrg plot( x, ..., plot.type = c("vs", "diff", "ts", "density"), pairs = c(1, 2), cumulative = FALSE, variable, id, span = 0.75 )

Arguments

...

data frames with APSIM output or observed data.

variable

variable to plot

index

index for merging objects. Default is ‘Date’

by

factor for splitting the comparison, such as a treatment effect.

labels

labels for plotting and identification of objects.

verbose

whether to print indexes to console (default is FALSE).

x

object of class ‘out_mrg’

digits

digits to print (default is 2)

plot.type

either ‘vs’, ‘diff’, ‘ts’ - for time series or ‘density’

pairs

pair of objects to compare, defaults to 1 and 2 but others are possible

cumulative

whether to plot cummulative values (default FALSE)

id

identification (not implemented yet)

span

argument passed to ‘geom_smooth’

Value

object of class ‘out_mrg’, which can be used for further plotting

it prints the index.table data.frame

it produces a plot

Examples

Run this code
# NOT RUN {
## Directory with files
extd.dir <- system.file("extdata", package = "apsimx")
## Comparing observed and simulated for Wheat
data(obsWheat)
sim.opt <- read.csv(file.path(extd.dir, "wheat-sim-opt.csv"))
sim.opt$Date <- as.Date(sim.opt$Date)

cap <- compare_apsim(obsWheat, sim.opt, labels = c("obs", "sim"))

plot(cap)
plot(cap, plot.type = "diff")
plot(cap, plot.type = "ts")

plot(cap, variable = "AboveGround")
plot(cap, variable = "AboveGround", plot.type = "diff")
plot(cap, variable = "AboveGround", plot.type = "ts")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab