Data Visualization and Statistical Tools for Agroindustrial Experiments

Set of tools for statistical analysis, visualization, and reporting of agroindustrial and agricultural experiments. The package provides functions to perform one-way and two-way ANOVA with post-hoc tests (Tukey HSD and Duncan MRT), Welch ANOVA for heteroscedastic data, and the Games-Howell post-hoc test as a robust alternative when variance homogeneity fails. When residual normality fails, the Kruskal-Wallis test (with 'agricolae' or Dunn post-hoc letters) or, for blocked designs, the Friedman test is used, so that letters are always obtained through a defensible route. Normality of residuals is assessed with the Shapiro-Wilk test and homoscedasticity with the Fligner-Killeen test; the appropriate statistical path is selected automatically based on these diagnostics. Coefficients of variation and statistical power (via one-way ANOVA power analysis) are reported alongside the post-hoc letter display, and each figure includes a note describing the statistical route used, its rationale, advantages, limitations and scope. High-level wrappers allow automated multi-variable analysis with optional clustering by one or two experimental factors, with support for custom level ordering and relabeling. Results are returned as 'ggplot2' boxplots with mean and letter annotations, wide-format summary tables ready for publication or LaTeX rendering, and structured decision summaries for rapid agronomic interpretation. Direct export to Excel spreadsheets and high-resolution image tables is also supported. Functions follow methods widely used in agronomy, field trials, and plant breeding. Key references: Tukey (1949) ; Duncan (1955) ; Welch (1951) ; Games and Howell (1976) ; Shapiro and Wilk (1965) ; Fligner and Killeen (1976) ; Kruskal and Wallis (1952) ; Dunn (1964) ; Friedman (1937) ; Cohen (1988, ISBN:9781138892899); Wickham (2016, ISBN:9783319242750) for 'ggplot2'; see also 'agricolae' < https://CRAN.R-project.org/package=agricolae> and 'rstatix' < https://CRAN.R-project.org/package=rstatix>. Version en espanol: Conjunto de herramientas para el analisis estadistico, visualizacion y generacion de reportes en ensayos agroindustriales y agricolas. Incluye ANOVA univariado y bifactorial con pruebas post-hoc (Tukey HSD y Duncan MRT), ANOVA de Welch para datos heterocedasticos y la prueba post-hoc de Games-Howell como alternativa robusta cuando falla la homogeneidad de varianzas. Cuando falla la normalidad de residuos se usa la prueba de Kruskal-Wallis (con letras de 'agricolae' o de Dunn) o, en disenos en bloques, la prueba de Friedman, de modo que las letras se obtienen siempre por una ruta defendible. La normalidad de residuos se evalua con la prueba de Shapiro-Wilk y la homogeneidad de varianzas con la prueba de Fligner-Killeen; la ruta estadistica apropiada se selecciona automaticamente segun estos diagnosticos. Se reportan coeficientes de variacion y potencia estadistica junto con las letras de separacion de medias, y cada grafico incluye una nota que describe la ruta estadistica usada, por que, sus ventajas, desventajas y alcance. Los envoltorios de alto nivel permiten analisis multivariable automatizado con agrupamiento opcional por uno o dos factores experimentales, con soporte para orden y etiquetado personalizado de niveles. Los resultados se devuelven como boxplots con anotaciones de medias y letras, tablas resumen en formato ancho listas para publicacion o renderizado en LaTeX, y resumenes de decision para interpretacion agronomica rapida. Tambien se soporta exportacion directa a Excel e imagenes de alta resolucion para informes tecnicos.


🌱 agrobox

Statistical analysis, visualization and decision support for agricultural experiments

CRANstatus CRANdownloads R-CMD-check


🌾 Why agrobox?

Agricultural experiments can be carefully designed, rigorously conducted, and full of valuable information.

But after collecting the data, researchers often face another challenge:

How do I turn my experimental data into a statistical result β€” and, more importantly, into a decision?

The statistical workflow can quickly become complicated:

Data β†’ Choose the model β†’ Check assumptions β†’ ANOVA β†’ Post-hoc β†’ Interpret β†’ Figure β†’ Decision

For researchers who are not specialized in R or statistics, this becomes a real barrier.

agrobox was created to reduce that barrier.

The goal is not to replace experimental design or statistical thinking. The goal is to make the analytical workflow:

  • βœ… Easier to access
  • βœ… Easier to reproduce
  • βœ… Easier to understand
  • βœ… Faster to execute
  • βœ… Closer to the final scientific decision

⚠️ agrobox does not rescue a poorly designed experiment.
It helps you get more efficiently from a well-designed experiment to its analysis and interpretation.


πŸš€ What is agrobox?

agrobox is an R package designed for statistical analysis, visualization, and reporting of agricultural and agroindustrial experiments.

It provides automated workflows for:

  • One-way and two-way ANOVA
  • Post-hoc comparisons (Tukey HSD, Duncan MRT, Games-Howell)
  • Heteroscedastic data (Welch ANOVA)
  • Non-parametric analysis (Kruskal-Wallis, Dunn, Friedman)
  • Statistical assumption checking (Shapiro-Wilk, Fligner-Killeen)
  • Coefficient of variation and statistical power
  • Publication-ready visualizations (ggplot2)
  • Multi-variable analysis and factor clustering
  • Excel export and high-resolution table export
  • Structured decision-oriented summaries

πŸ“¦ Installation

Install the stable version from CRAN:

install.packages("agrobox")

Then load the package:

library(agrobox)

🧠 Core idea: agrobox()

The main function organizes the entire statistical workflow around your experimental factors and response variable:

resultado <- agrobox(
  data     = datos,
  factor   = "tratamiento",
  variable = "rendimiento"
)

resultado

The function automatically evaluates the statistical assumptions and selects the appropriate analysis path. The goal is simple: place the grouping letters through a viable and defensible statistical route.

Clusters (one panel per group combination)
        ↓
Sufficient data? (β‰₯ 2 treatments, β‰₯ 3 obs. per treatment)
        ↓
Shapiro-Wilk (normality of residuals)
        ↓
Fligner-Killeen (homogeneity of variances)
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ A  Normal +          β”‚  β”‚ B  Normal +          β”‚  β”‚ C  Not normal +      β”‚  β”‚ D  Not normal +      β”‚
β”‚    homogeneous       β”‚  β”‚    heteroscedastic   β”‚  β”‚    homogeneous       β”‚  β”‚    heteroscedastic   β”‚
β”‚                      β”‚  β”‚                      β”‚  β”‚                      β”‚  β”‚                      β”‚
β”‚       ANOVA          β”‚  β”‚     Welch ANOVA      β”‚  β”‚  Kruskal-Wallis      β”‚  β”‚  Same as C + note    β”‚
β”‚         ↓            β”‚  β”‚          ↓           β”‚  β”‚  (or Friedman with   β”‚  β”‚  on heterogeneous    β”‚
β”‚  Tukey / Duncan      β”‚  β”‚    Games-Howell      β”‚  β”‚   blocks) / Dunn     β”‚  β”‚  variances           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Block and second factor are then handled within the selected route. If a post-hoc test cannot be computed, the next viable route is tried, and each figure includes a note explaining which route was used and why.

Since version 0.4.0 the route is selected automatically; the var.equal argument is kept only for backward compatibility.

The researcher does not need to manually reproduce every step for every variable.


πŸ”¬ Statistical workflow

Parametric analysis - One-way and two-way ANOVA - Tukey HSD - Duncan Multiple Range Test

Robust analysis (when variance homogeneity is not supported) - Welch ANOVA - Games-Howell post-hoc test

Non-parametric analysis (when residual normality is not supported) - Kruskal-Wallis with agricolae letters or Dunn post-hoc test (np_test) - Friedman test for blocked designs (RCBD) - P-value adjustment selectable with p.adj (default Bonferroni)

Diagnostics - Shapiro-Wilk test for residual normality - Fligner-Killeen test for homogeneity of variances

Additional output - Coefficient of variation (CV) - Statistical power - Means, grouping letters, and significance annotations - Statistical route used in each panel ($stats: route, method, p-value and notes)


πŸ“Š Visualization

agrobox() returns ggplot2-based figures ready for publication, including:

  • Experimental means
  • Statistical grouping letters
  • Boxplots with treatment comparisons
  • CV and statistical power annotations
  • A method note describing the statistical route used, why, its advantages, limitations, and scope

The output can be further customized using the full ggplot2 ecosystem.


🧩 Multiple factors and experimental structures

Agricultural experiments frequently involve more than one factor (e.g., Variety Γ— Treatment, Treatment Γ— Location).

agrobox() supports one and two experimental factors, with options for:

  • Factor ordering and relabeling
  • Grouping and clustering
  • Block information (RCBD)
  • Customized graphical output

🧠 agrosintesis() β€” From numbers to decisions

A single experiment rarely measures only one variable. You might record yield, fruit weight, firmness, color, soluble solids, acidity, incidence, severity β€” and more.

Running each analysis independently produces a lot of output without necessarily making the experiment easier to understand.

agrosintesis() solves this.

It applies the agrobox() workflow to multiple response variables simultaneously and consolidates the results into a structured, decision-oriented synthesis:

resultado <- agrosintesis(
  data      = datos,
  variables = c("rendimiento", "peso_fruto", "firmeza", "solidos_solubles")
)

Instead of:

Variable 1 β†’ analysis
Variable 2 β†’ analysis
Variable 3 β†’ analysis

You get:

EXPERIMENT
    ↓
Variable 1 + Variable 2 + Variable 3
    ↓             ↓             ↓
 Analysis      Analysis      Analysis
         \        |        /
          agrosintesis()
                ↓
           SYNTHESIS
                ↓
           DECISION

Statistical analysis should help you understand the experiment, not just produce more numbers.


πŸ“‘ agrotabla() β€” Publication-ready tables

Export statistical results as high-resolution images suitable for reports, presentations, and scientific publications:

agrotabla(resultado)

πŸ“Š agroexcel() β€” Excel export

Export results directly to Excel, organized by variable and experimental cluster:

agroexcel(resultado)

Particularly useful when an experiment contains several variables β€” results are organized into worksheets, eliminating manual copy-paste from R to Excel.


πŸ§ͺ A typical workflow

library(agrobox)

# Single variable
resultado <- agrobox(
  data     = datos,
  factor   = "tratamiento",
  variable = "rendimiento"
)

resultado

# Multiple variables
resultado <- agrosintesis(
  data      = datos,
  variables = c("rendimiento", "peso", "firmeza", "calidad")
)

# Export
agroexcel(resultado)
agrotabla(resultado)

The complete pipeline:

EXPERIMENTAL DATA
       ↓
   agrobox()
       ↓
Statistical diagnostics β†’ Analysis β†’ Post-hoc β†’ Graphics
       ↓
 agrosintesis()
       ↓
    SYNTHESIS
       ↓
    DECISION
       ↓
Excel / Tables

⚠️ What agrobox does NOT do

agrobox simplifies the statistical workflow. It does not replace experimental design or statistical reasoning.

No package can compensate for:

  • Poor experimental design
  • Pseudoreplication
  • Inadequate randomization
  • Insufficient replication
  • Uncontrolled sources of variation

Good statistics cannot rescue bad experimental design.
When the experiment has been designed correctly, agrobox makes the analysis more accessible and reproducible.


πŸ’‘ Help shape agrobox

agrobox is open source. Its development is driven by real agricultural problems.

If you find yourself thinking β€œI wish agrobox could do this…” β€” please tell me.

When reporting a bug, please include: your R version, your agrobox version, a reproducible example, the error message, and what you expected to happen.


🀝 Contributing

Contributions are welcome. You can help by:

  • Reporting bugs
  • Suggesting new features or experimental designs
  • Improving documentation
  • Sharing reproducible examples
  • Submitting pull requests

Every contribution helps make statistical analysis more accessible to agricultural researchers.


πŸ“š Scientific methods

The procedures implemented in agrobox are based on established statistical methods:

Method Reference
Tukey HSD Tukey (1949)
Duncan Multiple Range Test Duncan (1955)
Welch ANOVA Welch (1951)
Games-Howell Games & Howell (1976)
Shapiro-Wilk Shapiro & Wilk (1965)
Fligner-Killeen Fligner & Killeen (1976)
Kruskal-Wallis Kruskal & Wallis (1952)
Dunn test Dunn (1964)
Friedman test Friedman (1937)
Statistical power Cohen (1988)

The package builds on the R ecosystem, including ggplot2 and agricolae.


🌱 Citation

If you use agrobox in your research, please cite the package:

citation("agrobox")

πŸ‘¨β€πŸ”¬ Author

Joaquin Alejandro Salinas Angeles
Agronomist & Agricultural Researcher

Interests: agricultural experimentation Β· statistical analysis Β· postharvest research Β· reproducible research Β· R programming


⭐ Support the project

If agrobox is useful to you:

  • ⭐ Star the repository
  • πŸ› Report problems
  • πŸ’‘ Suggest improvements
  • πŸ“’ Share it with another researcher

🌾 From experiment to decision β€” let’s make agricultural statistics more accessible.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("agrobox")

0.4.0 by Joaquin Alejandro Salinas Angeles, 15 hours ago


https://github.com/Joa3aquin50/agrobox


Report a bug at https://github.com/Joa3aquin50/agrobox/issues


Browse source code at https://github.com/cran/agrobox


Authors: Joaquin Alejandro Salinas Angeles [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports dplyr, ggplot2, tidyr, stringr, agricolae, stats, pwr, rlang, openxlsx, rstatix, multcompView

Suggests kableExtra, magick, tinytex, cli, officer, rvg, testthat


See at CRAN