## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(MineSDG)

## -----------------------------------------------------------------------------
rep <- generate_gri_report(demo_mine_sites, site_id = "CU-ATAC",
                           years = 2022:2024)
rep

## -----------------------------------------------------------------------------
bundle <- compile_site_disclosures(
  demo_mine_sites, site_id = "CU-ATAC", years = 2022:2024,
  narratives = list(
    nar_water_mgmt = "Site water is managed under a catchment-level
      stewardship plan with quarterly community review."),
  entity_meta = list(company = "Atacama Copper SpA"))
bundle

bundle_kpi(bundle, "ghg_intensity")
bundle_raw(bundle, "ghg_scope1_t")
bundle_score(bundle, "goal_8")

## -----------------------------------------------------------------------------
framework_crosswalk("gri")[1:6, c("disclosure_id", "disclosure_title",
                                  "source_type", "source_id")]

## -----------------------------------------------------------------------------
m <- map_bundle_to_framework(bundle, "gri")
m

## -----------------------------------------------------------------------------
head(gri_content_index(rep), 8)

## -----------------------------------------------------------------------------
icmm <- generate_icmm_report(demo_mine_sites, site_id = "CU-ATAC",
                             years = 2023:2024)
icmm$extras$traffic_lights[, c("kpi_id", "value", "score", "light")]
icmm$extras$recommendations[, c("principle", "recommendation")]

## -----------------------------------------------------------------------------
kpis <- generate_brsr_kpis(
  demo_mine_sites, site_id = "CO-JHAR", years = 2023:2024,
  entity_meta = list(fx_usd_inr = 83.2))
kpis[, c("disclosure_id", "disclosure_title", "value", "status")]

## ----eval = FALSE-------------------------------------------------------------
# # HTML / PDF / DOCX via the packaged Quarto templates
# render_minesdg_report(rep, "gri_2024.html", format = "html")
# render_minesdg_report(rep, "gri_2024.pdf",  format = "pdf")
# 
# # Styled Excel workbook of the disclosure tables
# write_report_xlsx(rep, "gri_2024.xlsx")
# 
# # One-liner: generate and render together
# generate_brsr_report(demo_mine_sites, site_id = "CO-JHAR",
#                      years = 2023:2024, output = "brsr.docx",
#                      format = "docx")

## ----fig.width = 7, fig.height = 5--------------------------------------------
score_portfolio_sdg(demo_mine_sites)[year == 2024]
plot_sdg_radar(bundle)
plot_domain_radar(bundle)

