R Under development (unstable) (2024-01-28 r85838 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## Testing the compare_apsim function > require(apsimx) Loading required package: apsimx APSIM(X) not found. If APSIM(X) is installed in an alternative location, set paths manually using 'apsimx_options' or 'apsim_options'. You can still try as the package will look into the registry (under Windows) > require(ggplot2) Loading required package: ggplot2 > apsimx_options(warn.versions = FALSE) > > run.test.compare.apsimx <- get(".run.local.tests", envir = apsimx.options) > > extd.dir <- system.file("extdata", package = "apsimx") > > if(run.test.compare.apsimx){ + + data(obsWheat) + sim.opt <- read.csv(file.path(extd.dir, "wheat-sim-opt.csv")) + sim.opt$Date <- as.Date(sim.opt$Date) + + ## Testing compare_apsim + 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") + + ## Adding the capability when the length of the index is equal to 2 + obsPheno <- read.csv("~/Dropbox/apsimx-other/pheno_optim/obsPheno.csv") + simPheno <- read.csv("~/Dropbox/apsimx-other/pheno_optim/simPheno.csv") + + obsPheno$Date <- as.Date(obsPheno$Date) + simPheno$Date <- as.Date(simPheno$Date) + + cmp <- compare_apsim(obsPheno, simPheno, index = c("report", "Date"), labels = c("Obs", "Sim")) + + plot(cmp) + plot(cmp, by = "report") + plot(cmp, by = "report", se = FALSE) + plot(cmp, by = "report", se = FALSE, facet = TRUE) + plot(cmp, by = "report", plot.type = "ts", facet = TRUE, se = FALSE) + + plot(cmp, by = "report", plot.type = "ts", facet = TRUE, se = FALSE) + + ggplot2::theme(legend.position = "top") + + } > > if(FALSE){ + + ### Testing inspired by a more complicated dataset? + sim.wheat <- read_apsim_all(src.dir = "~/Dropbox/apsimx-other/KeLiu/mcmc_test/mcmc_test") + sim.wheat$outfile <- as.factor(sim.wheat$outfile) + ## obs.wheat <- as.data.frame(readxl::read_excel("~/Dropbox/apsimx-other/KeLiu/mcmc_test/mcmc_test/Obs.xlsx")) + obs.wheat$outfile <- as.factor(obs.wheat$outfile) + obs.wheat$Date <- as.Date(obs.wheat$Date) + + cmp1 <- compare_apsim(obs.wheat, sim.wheat, + labels = c("obs", "sim")) + + cmp1 <- compare_apsim(obs.wheat, sim.wheat, index = c("outfile", "Date"), + labels = c("obs", "sim")) + + plot(cmp1) + plot(cmp1, by = "outfile") + plot(cmp1, by = "outfile", se = FALSE) + plot(cmp1, by = "outfile", plot.type = "ts", facet = TRUE, se = FALSE) + + } > > proc.time() user system elapsed 1.31 0.31 1.61