From ebfabfcd81f34aced7a402fe67d4a85c8ca19083 Mon Sep 17 00:00:00 2001 From: Ben Bond-Lamberty Date: Mon, 5 Oct 2020 11:25:34 -0400 Subject: [PATCH] Compute Js for top-three PAR hours for each day See #37 --- R/sapflow-Rs.Rmd | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/R/sapflow-Rs.Rmd b/R/sapflow-Rs.Rmd index 0448480..05869e2 100644 --- a/R/sapflow-Rs.Rmd +++ b/R/sapflow-Rs.Rmd @@ -260,6 +260,15 @@ sapflow_js %>% complete(Tree, Timestamp = seq(min(Timestamp), max(Timestamp), by = "hour")) %>% log_obs("combined") -> combined +# For each tree and date, grab the three rows with maximum PAR, compute the mean Js +# for those rows, and then merge the result back into `combined`. +combined %>% + group_by(Tree, Date) %>% + slice_max(PAR, n = 3) %>% + summarise(Js_maxPAR = mean(Js_avg, na.rm = TRUE)) %>% + right_join(combined, by = c("Tree", "Date")) -> + combined + # At this point, `combined` holds rs, js, and weather data rounded to the nearest hour # Here the data are joined and include any NAs or NaNs in any column