# create a QUEFTS model
# 1. get parameters
soiltype <- quefts_soil()
barley <- quefts_crop("Barley")
fertilizer <- list(N=0, P=0, K=0)
att_yield <- list(leaf_att=2200, stem_att=2700, store_att=4800, SeasonLength=110)
# 2. create a model
q <- quefts(soiltype, barley, fertilizer, att_yield)
# 3. run the model
run(q)
# change some parameters
q$SeasonLength <- 162
q$leaf_att <- 2651
q$stem_att <- 5053
q$store_att <- 8208
q$N <- 100
q$P <- 50
q$K <- 50
run(q)
## note that Rquefts uses C++ reference classes.
## This means that if you copy a quefts model, you do not create a
## new instance of the model, but you point to the same one!
q <- quefts()
q["N"]
k <- q
k["N"] <- 150
k["N"]
# the value of q has also changed!
q["N"]
## different ways of subsetting / replacement
q <- quefts()
q$N
q$N <- 30
q["N"]
q["N"] <- 90
q["model", "N"]
q["model", "N"] <- 60
q$N
q$soil$N_recovery
q["soil$N_recovery"]
q["soil$N_recovery"] <- .6
q["soil", "N_recovery"]
q["soil", "N_recovery"] <- .4
q$soil$N_recovery
Run the code above in your browser using DataLab