Description Usage Arguments Details Value Examples
APSIM helper files, such as "Soil.xml", have a different format from .apsim files and are therefore handled separately
1 | edit_sim_file(file, wd = getwd(), var, value, overwrite = FALSE)
|
file |
.xml module file to be edited |
wd |
directory containing the .xml file to be edited; defaults to the current wd |
var |
vector of variables to be edited |
value |
list of new values for the specified variables |
overwrite |
logical; if |
APSIM uses .xml files to dictate how certain processes are carried out. Similar to
edit_apsim
this function edits a file that will be used in an APSIM simulation. Unlike
edit_apsim
this function edits the .xml simulation files.
The variables specified by var
within the .xml file specified by file
in the working directory wd
are edited. The old values are replaced with value
, which
is a list that has the same number of elements as the vector var
is long. The current
.xml file will be overwritten if overwrite
is set to TRUE
; otherwise the file
file-edited.xml will be created. If the file was successfully edited, then the name
of the written file is returned.
complete file path to edited simulation file is returned as a character string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ## Not run:
#The file I want to edit is called "Soil.xml" which is the the directory "~/APSIM"
simFile <- "Soil.xml"
apsimWd <- "~/APSIM"
#I want to change the potential nitrification and N2O from nitrification
simVar <- c("nitrification_pot", "dnit_nitrf_loss","wfnit_values")
#Change both to absolute values of random N(0,1)
simValue <- list(abs(rnorm(1)), abs(rnorm(1)), c(0,2,2,1))
#Edit Soil.xml without overwriting it
edit_sim_file(file = simFile, wd = apsimWd, var = simVar, value = simValue, overwrite = FALSE)
#Passing an .apsim file to edit_sim_file will give a warning and redirect it to edit_apsim
apsimFile <- "Canopy.apsim"
apsimValue <- list(c(rep(200, 2), rep(300, 9)), 9, "NSW")
apsimVar <- c("SoilWater/Thickness", "SoilOrganicMatter/SoilCN", "State")
edit_sim_file(file = apsimFile, wd = apsimWd, var = apsimVar, value = apsimValue, overwrite = FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.