Convert an agricolae field book for saving to Breedbase
Source:R/as_breedbase_design.R
as_breedbase_design.RdAdapts a design generated by the CRAN package agricolae to
save_breedbase() and phenotype_template(). The randomization is kept;
no design is generated or randomized by this function. Conversion is
entirely offline and does not require agricolae to be installed.
To also record the trial name, location, breeding program and year for
a later save, use prepare_breedbase_trial().
Usage
as_breedbase_design(
design,
accession = NULL,
checks = NULL,
design_type = NULL,
plot = NULL,
block = NULL,
rep = NULL,
row = NULL,
col = NULL
)Arguments
- design
An agricolae design (a list with
bookandparameters), or its field-book data frame, including the result ofagricolae::zigzag().- accession
Name of the field-book column containing Breedbase accession names. Inferred only when exactly one non-structural column is present. For factorial, split-plot, strip-plot and Graeco-Latin designs, explicitly select the genotype column; combinations of treatment factors are not turned into accession names.
- checks
Character vector of check accession names. By default, uses
parameters$trt1for an agricolae augmented block design (design.dau()), and no checks for other designs. Usecharacter(0)to explicitly mark no checks.- design_type
Breedbase design type. Inferred for
crd("CRD"),rcbd("RCBD"),alpha("Alpha"),lattice("Lattice"),dau("Augmented"),split("splitplot") andstrip("stripplot"); factorial designs use their underlying CRD or RCBD. Required for a bare field book or a design without a direct Breedbase type, such as Latin squares, Youden, BIB and cyclic designs. Select a compatible type accepted by your Breedbase installation; the original agricolae type remains in the returned object'sparameters.- plot, block, rep, row, col
Optional field-book column names. Defaults detect
plots,block, a replicate column (replication,replicate,reporr), and the pairrow,col. Missing block or replicate columns are set to 1; in RCBD, block also supplies replicate. Augmented blocks are not treated as replicates. Coordinates are used only when both columns are available, and are never inferred from plot numbers or the sketch. Mapped numeric columns must contain positive integers.
Value
A breedbase_design list with the standardized plot table
(design), Breedbase design_type, original book and parameters.
Pass the whole object to save_breedbase() or phenotype_template().
Details
Plot numbers, accessions, blocks, replicates and any explicit coordinates
retain their field-book values. Alpha designs' cols column describes
positions within blocks and is not assumed to be a field coordinate.
For split plots, where plots is repeated across subplots, sequential
unique plot numbers are assigned in field-book row order. An explicit
plot mapping must always identify each row uniquely.
The original field book and generation parameters are retained as
book and parameters. Saving uploads one plot per row, with accession,
block, replicate, check status and optional coordinates. Other treatment
factors and the main-plot/subplot hierarchy are retained locally, but are
not uploaded by save_breedbase(). In particular, this conversion does
not create treatment records or an analysis model for factorial designs.
Accession names must already exist in Breedbase. Supply the new trial's
name, year, location, description and breeding program to
save_breedbase(); use dry_run = TRUE to inspect or check before saving.
Examples
if (requireNamespace("agricolae", quietly = TRUE)) {
accessions <- c("G1", "G2", "G3", "CHECK_A")
randomized <- agricolae::design.rcbd(accessions, r = 3, seed = 2026)
converted <- as_breedbase_design(randomized, checks = "CHECK_A")
payload <- save_breedbase(converted, trial_name = "RCBD_2026",
year = 2026, location = "Ibadan", description = "RCBD from agricolae",
dry_run = TRUE)
sheet <- phenotype_template(converted, "RCBD_2026", traits = "yield")
}
#> Dry run without a connection: returning the data that would be sent.