From 1beb5b69460350a2a21c2ba0b6ba66806c4a63e3 Mon Sep 17 00:00:00 2001 From: biopsichas <svajunas.plunge@gmail.com> Date: Mon, 2 Oct 2023 17:11:23 +0300 Subject: [PATCH] fixed error for plotting phu with short time series --- R/plot_mgt_harv.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/plot_mgt_harv.R b/R/plot_mgt_harv.R index c24872c..52db5c8 100644 --- a/R/plot_mgt_harv.R +++ b/R/plot_mgt_harv.R @@ -270,7 +270,8 @@ prepare_phu <- function(mgt_out, years) { group_by(hru, year, op_typ) %>% # ungroup() %>% # filter(n_op > 1) %>% - mutate(date_diff = diff(date)) %>% + # mutate(date_diff = diff(date)) %>% + mutate(date_diff = lead(date)-date) %>% ##This line avoids error if only one year for crop is available without kill ungroup() %>% filter(year %in% years) -- GitLab