## Selected calculations
## library(tidyverse) # purrr used here for crop2 example
library(dplyr)
library(purrr)
cumulative(boonah, enddate = crop$flower_date[4], ndays = 3,
monitor = TRUE)
cumulative(boonah, enddate = crop$harvest_date[4], ndays = 3,
monitor = TRUE)
cumulative(boonah, startdate = crop$flower_date[4],
enddate = crop$harvest_date[4], monitor = TRUE)
cumulative(boonah, startdate = crop$flower_date[4],
enddate = crop$harvest_date[4])
cumulative(boonah, var = rain, startdate = crop$flower_date[4],
enddate = crop$harvest_date[4])
## Add selected totals of weather variables in 'boonah' to 'crop'' tibble
## using 'map2_dbl' from the 'purrr' package
## Note: using equivalent 'furrr' functions can speed up calculations
crop2 <- crop |>
dplyr::mutate(totalrain_post_sow_7d =
purrr::map_dbl(sowing_date, function(x)
cumulative(boonah, var = rain, startdate = x, ndays = 7)),
totalrad_flower_harvest =
purrr::map2_dbl(flower_date, harvest_date, function(x, y)
cumulative(boonah, var = radn, startdate = x, enddate = y)))
crop2
Run the code above in your browser using DataLab