modified: r_app/91_CI_report_with_kpis_cane_supply.Rmd

This commit is contained in:
Timon 2026-02-10 19:17:12 +01:00
parent 5ba610d897
commit 8de05ce968

View file

@ -396,6 +396,17 @@ if (!is.null(benchmarks)) {
}
```
```{r compute_total_acreage, include=FALSE, eval=TRUE}
# Precompute total acreage for use in cover page inline expression
# Safely extract and sum acreage from KPI data (may not exist until key_insights runs)
total_acreage <- 0
if (exists("summary_data") && !is.null(summary_data) && "field_analysis" %in% names(summary_data)) {
field_analysis_df <- summary_data$field_analysis
total_acreage <- sum(field_analysis_df$Acreage, na.rm = TRUE)
if (is.na(total_acreage)) total_acreage <- 0
}
```
<!-- Dynamic cover page -->
::: {custom-style="Cover_title" style="text-align:center; margin-top:120px;"}
@ -408,19 +419,15 @@ if (!is.null(benchmarks)) {
\newpage
## Report Generated
**Farm Location:** `r toupper(project_dir)` Estate
**Report Period:** Week `r current_week` of `r year`
**Report Generated on:** `r format(Sys.time(), "%B %d, %Y at %H:%M")`
**Farm Size Included in Analysis:** `r toupper(total_acreage)` acres
**Farm Size Included in Analysis:** `r formatC(total_acreage, format="f", digits=1)` acres
**Data Source:** Planet Labs Satellite Imagery
**Analysis Type:** Chlorophyll Index (CI) Monitoring
## Key Insights
```{r key_insights, echo=FALSE, results='asis', eval=TRUE}