Skip to content

Commit

Permalink
Fixed warning for calc_sombalance
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenVw committed Oct 21, 2019
1 parent 3acf002 commit 036e521
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions R/sombalance.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @export
calc_sombalance <- function(A_OS_GV, A_P_PAL, A_P_WA, B_LU_BRP,M_M3, M_M6) {

c.diss = id = crop_code = crop_name = crop_n = cropinput = mdose = compost = catchcrop = NULL
c.diss = crop_code = crop_name = crop_n = cropinput = mdose = compost = catchcrop = NULL
crop_eos = crop_eos_residue = NULL

# Load in the datasets
Expand Down Expand Up @@ -72,12 +72,14 @@ calc_sombalance <- function(A_OS_GV, A_P_PAL, A_P_WA, B_LU_BRP,M_M3, M_M6) {
dt[crop_n=='akkerbouw' & A_P_WA > 55,mdose := 0.85 * 50 * slurry_EOS_Pratio]

# EOS input via compost to arable soils
dt[crop_n == 'akkerbouw', compost := ifelse(M_M3 == 0, 0, 15 * 218 / M_M3) ]
dt[crop_n != 'akkerbouw', compost := 0 ]
dt[crop_n == 'akkerbouw' & M_M3 == 0, compost := 0]
dt[crop_n == 'akkerbouw' & M_M3 != 0, compost := 15 * 218 / M_M3]
dt[crop_n != 'akkerbouw', compost := 0]

# EOS input via catch crops (and mandatory crops)
dt[,catchcrop := ifelse(M_M6,850,0)]
dt[grepl('mais|aardappel',crop_name),catchcrop := 850]
dt[M_M6 == TRUE, catchcrop := 850]
dt[M_M6 != TRUE, catchcrop := 0]
dt[grepl('mais|aardappel',crop_name), catchcrop := 850]

# calculate simple eos balance (kg EOS / ha / yr)
dt[,value := cropinput + mdose + compost + catchcrop - c.diss]
Expand Down

0 comments on commit 036e521

Please sign in to comment.