## Not run:
# #The file I want to edit is called "Canopy.apsim" which is in the directory "~/APSIM"
# apsimFile <- "Canopy.apsim"
# apsimWd <- "~/APSIM"
#
# #I want to change the Thickness of the Soilwater, the SoilCN of the SoilOrganicMatter and
# #the state at which the simulation is being run.
# apsimVar <- c("SoilWater/Thickness", "SoilOrganicMatter/SoilCN", "State")
#
# #Change SoilWater-Thickness to 200,200,300x9
# #Change SoilCN to 10
# #Change "State" to "NSW"
# apsimValue <- list(c(rep(200, 2), rep(300, 9)), 9, "NSW")
#
# #Edit the apsim file without overwriting it
# edit_apsim(file = apsimFile, wd = apsimWd, var = apsimVar, value = apsimValue, overwrite = FALSE)
#
# #Run the edited simulation
# apsimExe <-"C:/Program Files (x86)/Apsim75-r3008/Model/Apsim.exe"
#
# results <- apsim(apsimExe, apsimWd, files = "Canopy-edited.apsim")
#
# #Passing a simulation file to edit_apsim will give you a warning and redirect it to edit_sim_file
# simFile <- "Soil.xml"
# simValue <- list(abs(rnorm(1)), abs(rnorm(1)), c(0,2,2,1))
# simVar <- c("nitrification_pot", "dnit_nitrf_loss","wfnit_values")
# edit_apsim(file = simFile, wd = apsimWd, var = simVar, value = simValue, overwrite = FALSE)
# ## End(Not run)
Run the code above in your browser using DataLab