Yield change: parameters and growing seasons
Organizing data related to parameters to compute yield changes provided by Agnolucci in the paper Impacts of rising temperatures and farm management practices on global yields of 18 crops. We use parameters for:
- wheat (march - july),
- barley (march - july),
- potatoes (march - july),
- oats (april - september),
- rapeseed (september - july).
Load packages, read data, and source custom scripts
rm(list = ls())
library(readxl)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tidyr)
path_proj <- day2day::git_path()
path_data <- file.path(path_proj, "data")
path_raw <- file.path(path_data, "raw")
path_cleaned <- file.path(path_data, "cleaned")
path_yield_params <- file.path(path_raw, "yield-params", "marginal_impacts.xlsx")
Clean yield parameters and define growing season
- Convert variable names to lower case,
- replace
NA
parameters to 0, - create data regarding growing season.
replace_na <- function(x) {
x[is.na(x)] <- 0
return(x)
}
yield_params <- read_xlsx(path_yield_params, sheet = 2, n_max = 4) %>%
rename(predictor = `...1`) %>%
rename_all(tolower) %>%
mutate(predictor = tolower(predictor)) %>%
mutate_all(replace_na)
#> New names:
#> * `` -> ...1
yield_season <- list(barley = 3:7,
oats = 4:9,
potatoes = 3:7,
rapeseed = c(9:12, 1:7),
wheat = 3:7)
yield <- list(params = yield_params, season = yield_season)
saveRDS(yield, file.path(path_cleaned, "yield-params-and-season.rds"))
Display yield’s parameters
knitr::kable(yield_params, "html", table.attr = "class=\"table\"", align = "lcrr",
caption = "Parameters to predict yield change")
predictor | barley | oats | potatoes | rapeseed | wheat |
---|---|---|---|---|---|
temp | 0.0720000 | 4.2e-02 | 0.065 | 1.0e-01 | 0.147000 |
temp2 | -0.0020000 | -2.0e-03 | -0.001 | -5.0e-03 | -0.005000 |
prec | -0.0002213 | 4.0e-04 | -0.002 | 1.0e-02 | 0.010000 |
prec2 | 0.0000000 | -6.0e-07 | 0.000 | -9.7e-06 | -0.000041 |
Display growing season
lapply(yield_season, function(x) month.name[x])
#> $barley
#> [1] "March" "April" "May" "June" "July"
#>
#> $oats
#> [1] "April" "May" "June" "July" "August" "September"
#>
#> $potatoes
#> [1] "March" "April" "May" "June" "July"
#>
#> $rapeseed
#> [1] "September" "October" "November" "December" "January" "February" "March" "April"
#> [9] "May" "June" "July"
#>
#> $wheat
#> [1] "March" "April" "May" "June" "July"
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 8.159 0.350 8.471