--- title: "tikatuwq: From raw water quality data to CONAMA report" author: "tikatuwq developers" output: rmarkdown::html_vignette: number_sections: true vignette: > %\VignetteIndexEntry{tikatuwq: From raw water quality data to CONAMA report} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4, dpi = 96, message = FALSE, warning = FALSE, fig.alt = "Figure generated by tikatuwq package" ) ``` ## Introduction The tikatuwq package provides a reproducible workflow for Brazilian water quality assessment. It implements common indices such as the IQA/WQI and Carlson or Lamparelli trophic state indices, together with CONAMA 357/2005 compliance checks, plotting helpers and basic reporting tools. The package now includes a real dataset containing water quality measurements collected by INEMA (Environmental Agency of Bahia) during monitoring campaigns between 2021 and 2024 in the Rio Buranhem watershed, Porto Seguro, Bahia, Brazil. This dataset is included for demonstration and reproducibility purposes, closely following the analytical workflow presented in this vignette. All variable names correspond to real monitoring attributes. In this vignette we demonstrate a typical pipeline: reading a raw CSV file, handling censored values (ND / % dplyr::select(data, ponto, turbidez, od, dbo, ph) %>% pivot_longer(cols = c(turbidez, od, dbo, ph), names_to = "parametro", values_to = "valor") # Heatmap p4 <- plot_heatmap(df_long) print(p4) ``` ## Generating a textual analysis and report The `generate_analysis()` function produces human-readable paragraphs summarizing water quality: ```{r generate-analysis} # Generate analytical text analysis_text <- generate_analysis( df_iqa, classe_conama = "2", incluir_tendencia = FALSE, # Set TRUE if you have temporal data contexto = list(river = "Demo River", period = "2025") ) cat(paste(analysis_text, collapse = "\n\n")) ``` For a full HTML report: ```{r render-report, eval=FALSE} # Generate HTML report (requires rmarkdown) # report_path <- render_report( # df_iqa, # meta = list(river = "Demo River", period = "2025"), # output_dir = tempdir() # ) # # # Open in browser # browseURL(report_path) ``` ## Summary and next steps This vignette demonstrated a complete workflow: 1. **Read data**: `read_wq()` with censored value handling 2. **Validate**: `validate_wq()` to check required columns 3. **Clean units**: `clean_units()` for unit conversion and validation 4. **Compute indices**: `iqa()` for water quality index 5. **Check compliance**: `conama_check()`, `conama_summary()`, `conama_report()` 6. **Visualize**: `plot_iqa()`, `plot_series()`, `plot_box()`, `plot_heatmap()` 7. **Report**: `generate_analysis()` and `render_report()` ### Next steps - Explore temporal trends with `trend_param()` and `plot_trend()` - Use `param_analysis()` functions for parameter-specific analysis - Create interactive maps with `plot_map()` if coordinates are available - Adapt the workflow to your own datasets For more details, see: - The methods vignette for index calculations and trend analysis - Package documentation: `help(package = "tikatuwq")` - Online documentation: https://tikatuwq.github.io/tikatuwq/