
Generate Randomized Experimental Layouts and Greenhouse/Field Planting Maps
Source:R/generate_layout.R
generate_layout.RdGenerates fully randomized field or greenhouse layouts for single-factor, 2-way, and 3-way factorials across CRD (DCA), RCBD (DBCA), Split-Plot, and Split-Split-Plot designs, providing unique plot IDs, randomized spatial coordinates (Row, Col, Table/Block), exportable data-collection CSV sheets, and publication-grade 2D bench croquis.
Arguments
- design
Design type: `"RCBD"` (DBCA / Bloques Completos al Azar), `"CRD"` (DCA / Completamente al Azar), `"Split-Plot"` (Parcelas Divididas, 2 factors with physical restriction), or `"Split-Split-Plot"` (Parcelas Sub-Subdivididas, 3 factors).
- treatments
Named list of treatment factor names and their levels. For Split-Plot: list with main-plot first, then sub-plot. For Split-Split-Plot: list with main-plot first, sub-plot second, sub-sub-plot third.
- replications
Number of blocks (for RCBD/Split-Plot) or replicates (for CRD).
- seed
Optional integer seed for reproducible random allocation.
- output_csv
Optional file path to export the ready-to-fill phenotyping template (e.g., `"planting_plan.csv"`).
Value
An S3 object of class `"agri_layout"` containing:
- layout_table
Data frame with plot IDs, block, spatial coordinates, treatment assignments, and an empty response column.
- design
Experimental design type.
- treatments
Treatment factors list.
- replications
Number of blocks or replicates.
- seed
Random seed used.
Examples
# Generate greenhouse DBCA layout for 5 genotyes across 4 tables/blocks
lay_rcbd <- generate_layout(
design = "RCBD",
treatments = list(genotype = paste0("G", 1:5)),
replications = 4,
seed = 42
)
print(lay_rcbd)
#>
#> ======================================================================
#> agriDesignR: Randomized Experimental Layout (RCBD)
#> ======================================================================
#> Design Type : RCBD
#> Factor Count : 1-Way Factorial (genotype)
#> Replications : 4 blocks / benches / reps
#> Total Units : 20 experimental plots / pots
#> Random Seed : 42
#>
#>
#> First 15 Randomized Planting Units (Preview)
#> ----------------------------------------------------------------------
#> Plot_ID Block Position_in_Block genotype response_value
#> P_001 Mesa_1 (Bloque 1) 1 G1 NA
#> P_002 Mesa_1 (Bloque 1) 2 G5 NA
#> P_003 Mesa_1 (Bloque 1) 3 G4 NA
#> P_004 Mesa_1 (Bloque 1) 4 G3 NA
#> P_005 Mesa_1 (Bloque 1) 5 G2 NA
#> P_006 Mesa_2 (Bloque 2) 1 G4 NA
#> P_007 Mesa_2 (Bloque 2) 2 G2 NA
#> P_008 Mesa_2 (Bloque 2) 3 G5 NA
#> P_009 Mesa_2 (Bloque 2) 4 G1 NA
#> P_010 Mesa_2 (Bloque 2) 5 G3 NA
#> P_011 Mesa_3 (Bloque 3) 1 G4 NA
#> P_012 Mesa_3 (Bloque 3) 2 G1 NA
#> P_013 Mesa_3 (Bloque 3) 3 G5 NA
#> P_014 Mesa_3 (Bloque 3) 4 G2 NA
#> P_015 Mesa_3 (Bloque 3) 5 G3 NA
#> ... [Total: 20 pots/plots. Access full data with '$layout_table']
#>
#> ======================================================================
#> Tip: Print or export to CSV. Fill 'response_value' during harvest, then run 'fit_experiment()'.
#>
# plot(lay_rcbd)