Package {FielDHub}


Title: A Shiny App for Design of Experiments in Life Sciences
Version: 1.7.6
Description: A shiny design of experiments (DOE) app that aids in the creation of traditional, un-replicated, augmented and partially-replicated designs applied to agriculture, plant breeding, forestry, animal and biological sciences.
Depends: R (≥ 4.1.0)
License: MIT + file LICENSE
Imports: dplyr (≥ 1.0.0), ggplot2 (≥ 3.4.0), rlang, viridisLite, desplot (≥ 1.11), shiny (≥ 1.8.1), htmltools, DT, bslib, promises, shinyjs
LinkingTo: cpp11
SystemRequirements: C++17
Encoding: UTF-8
RoxygenNote: 7.3.2
Author: Didier Murillo [cre, aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Matthew Seefeldt [ctb], Jean-Marc Montpetit [ctb], Richard Horsley [ctb], North Dakota State University [cph]
Maintainer: Didier Murillo <didier.murilloflorez@ndsu.edu>
Suggests: mirai, later, codetools, testthat (≥ 3.2.0), spelling, knitr, rmarkdown
Config/testthat/edition: 3
URL: https://github.com/DidierMurilloF/FielDHub, https://didiermurillof.github.io/FielDHub/
BugReports: https://github.com/DidierMurilloF/FielDHub/issues
Language: en-US
VignetteBuilder: knitr
NeedsCompilation: yes
Packaged: 2026-11-29 01:17:24 UTC; didier.murilloflorez
Repository: CRAN
Date/Publication: 2026-11-29 04:00:08 UTC

Generates a Completely Randomized Design (CRD)

Description

It randomly generates a completely randomized design.

Usage

CRD(
  t = NULL,
  reps = NULL,
  plotNumber = 101,
  locationName = NULL,
  seed = NULL,
  data = NULL,
  locationNames = NULL,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

t

An integer number with total number of treatments or a vector of dimension t with labels.

reps

One positive whole-number count of replicates per treatment.

plotNumber

Starting plot number. By default plotNumber = 101.

locationName

Deprecated spelling of locationNames. Existing positional calls remain supported, with a deprecation warning.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

data

(optional) Data frame whose first two columns contain unique treatment labels and positive whole-number replication counts. Extra columns are ignored; rows missing either selected value are omitted.

locationNames

(optional) Name of the single location. Supply only one of locationNames and locationName.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the serpentine planting path of the whole field. See field_layout for how the design is placed.

stacked

The stacking of the replicates of the designs in blocks. A completely randomized design has no replicates to stack: giving stacked is an error.

Details

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(CRD, x$metadata$parameters). Data inputs are recorded after the existing column selection and normalization.

Value

A list with three elements.

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

References

Federer, W. T. (1955). Experimental Design. Theory and Application. New York, USA. The Macmillan Company.

Examples

# Example 1: Generates a CRD design with 10 treatments and 5 reps each.
crd1 <- CRD(
  t = 10,
  reps = 5,
  plotNumber = 101,
  seed = 1987,
  locationNames = "Fargo"
)
crd1$infoDesign
head(crd1$fieldBook, 10)

# Example 2: Generates a CRD design with 15 treatments and 6 reps each.
Gens <- paste("Wheat", 1:15, sep = "")
crd2 <- CRD(
  t = Gens,
  reps = 6,
  plotNumber = 1001,
  seed = 1654,
  locationNames = "Fargo"
)
crd2$infoDesign
head(crd2$fieldBook, 10)

# Example 3: Generates a CRD design with 12 treatments and 4 reps each.
# In this case, we show how to use the option data.
treatments <- paste("ND-", 1:12, sep = "")
treatment_list <- data.frame(list(TREATMENT = treatments, REP = 4))
head(treatment_list)
crd3 <- CRD(
  t = NULL,
  reps = NULL,
  plotNumber = 2001,
  seed = 1655,
  locationNames = "Cali",
  data = treatment_list
)
crd3$infoDesign
head(crd3$fieldBook, 10)


Generates a Randomized Complete Block Design (RCBD)

Description

It randomly generates a randomized complete block design (RCBD) across locations.

Usage

RCBD(
  t = NULL,
  reps = NULL,
  l = 1,
  plotNumber = 101,
  continuous = FALSE,
  planter = "serpentine",
  seed = NULL,
  locationNames = NULL,
  data = NULL,
  checks = NULL,
  rep_checks = NULL,
  spread_checks = TRUE,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

t

An integer number with total number of treatments or a vector of dimension t with labels.

reps

Number of replicates (full blocks) of each treatment.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

continuous

Logical value for plot number continuous or not. By default continuous = FALSE.

planter

Option for serpentine or cartesian arrangement. By default planter = 'serpentine'.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

locationNames

(optional) Names for each location.

data

(optional) Data frame with the labels of treatments.

checks

(optional) Checks to repeat within every block. Either a positive integer N or a character vector of check labels. When data or a character vector t supplies a pool of entries, N takes that pool's first N entries as the checks; when no pool is supplied (t is a bare count), N instead generates its own check labels "CH1".."CHN" ahead of the auto-generated test entries "T1".."Tt". checks sits after data in the argument list (rather than next to t, where it might otherwise go) precisely so that data keeps its original positional slot and existing positional calls to RCBD() keep working unchanged. By default checks = NULL, which produces an ordinary RCBD.

rep_checks

(optional) Number of times each check is repeated within every block. A single value is recycled across all checks, or supply one value per check. By default rep_checks = NULL, which is treated as 1 for every check.

spread_checks

(optional) Logical. When TRUE (the default), the repeated copies of each check are spread across the block by placing one copy in each of rep_checks contiguous strata. When FALSE, the whole block is randomized without restriction.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots, including repeated checks. The complete blocks are then equal rectangles of the field, and the plots are numbered along the planting path of the whole field (see planter): the numbering does not restart in each block, so with continuous = FALSE the hundreds of a plot number name the block only where the blocks lie one above the other. See field_layout for how the blocks are placed.

stacked

How the blocks of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of blocks). It needs nrows or ncols. By default the arrangement whose block is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout.

Details

The result records effective inputs, the resolved seed and the starting plot numbers in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(RCBD, x$metadata$parameters).

When checks is supplied, one or more checks are repeated multiple times within every block, while every test entry still appears exactly once. In a classical RCBD, the residual is the treatment-by-block interaction; repeating checks inside a block instead supplies a within-block estimate of error and a form of local control.

checks accepts either a single positive integer N or a character vector of check labels. When a pool of entries is supplied through data or a character t, an integer N takes the first N entries of that pool as the checks, and a character vector of labels must already exist in that pool; an unmatched label is an error that also names the closest case-insensitive match, if any. When no pool is supplied (t is a bare count), the labels are generated instead: a character checks is appended to the auto-generated test entries, while an integer N generates its own check labels "CH1".."CHN" ahead of the auto-generated test entries "T1".."Tt".

rep_checks sets how many times each check repeats within a block: a single value is recycled across all checks, or one value can be supplied per check.

A block (test entries plus repeated checks) larger than 10,000 plots is rejected.

With spread_checks = TRUE (the default), the repeated copies of a check are placed one per contiguous stratum of the block, so they are spread across it rather than clustered together. Two distinct density facts apply here: as soon as checks occupy more than 50 percent of the block, a warning is issued as an early caution, but randomization itself remains effectively unconstrained up to about 67 percent check density; only from about 78 percent and higher does the stratified-placement constraint leave few or no alternative positions, so a repeated check's placement can become nearly or fully deterministic rather than random. This is a property of the stratified-placement geometry, not a bug, and most field trials use far lower check density than either threshold.

Value

A list with five elements.

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

References

Federer, W. T. (1955). Experimental Design. Theory and Application. New York, USA. The Macmillan Company.

Lin, C.S., & Poushinsky, G. (1985). A modified augmented design (type 2) for rectangular plots. Canadian Journal of Plant Science, 65(3), 743-749.

Examples

# Example 1: Generates a RCBD design with 3 blocks and 20 treatments across 3 locations.
rcbd1 <- RCBD(t = LETTERS[1:20], reps = 5, l = 3, 
              plotNumber = c(101,1001, 2001), 
              continuous = TRUE,
              planter = "serpentine", 
              seed = 1020, 
              locationNames = c("FARGO", "MINOT", "CASSELTON"))
rcbd1$infoDesign                  
rcbd1$layoutRandom
rcbd1$plotNumber
head(rcbd1$fieldBook)

# Example 2: Generates a RCBD design with 6 blocks and 18 treatments in one location.
# In this case, we show how to use the option data.
treatments <- paste("ND-", 1:18, sep = "")
treatment_list <- data.frame(list(TREATMENT = treatments))
head(treatment_list)
rcbd2 <- RCBD(reps = 6, l = 1, 
              plotNumber = 101, 
              continuous = FALSE, 
              planter = "serpentine", 
              seed = 13, 
              locationNames = "IBAGUE",
              data = treatment_list)
rcbd2$infoDesign
rcbd2$layoutRandom
rcbd2$plotNumber
head(rcbd2$fieldBook)

# Example 3: RCBD with two checks repeated twice in each of 3 blocks,
# alongside 18 test entries. Block size is 18 + 2 + 2 = 22 plots.
rcbd3 <- RCBD(t = 18, reps = 3,
              checks = c("CK1", "CK2"),
              rep_checks = c(2, 2),
              plotNumber = 101,
              seed = 1234,
              locationNames = "FARGO")
rcbd3$infoDesign
head(rcbd3$fieldBook)
# Each check appears twice per block, every test entry exactly once:
table(subset(rcbd3$fieldBook, REP == 1)$TREATMENT)


Generates an Augmented Randomized Complete Block Design (ARCBD)

Description

It randomly generates an augmented randomized complete block design across locations (ARCBD).

Usage

RCBD_augmented(
  lines = NULL,
  checks = NULL,
  b = NULL,
  l = 1,
  planter = "serpentine",
  plotNumber = 101,
  repsStack = c("vertical", "horizontal"),
  exptName = NULL,
  seed = NULL,
  locationNames = NULL,
  repsExpt = 1,
  random = TRUE,
  data = NULL,
  nrows = NULL,
  ncols = NULL,
  year = NULL,
  plotIncrement = NULL
)

Arguments

lines

Treatments, number of lines for test.

checks

Number of checks per augmented block.

b

Number of augmented blocks.

l

Number of locations. By default l = 1.

planter

Option for serpentine or cartesian arrangement. By default planter = 'serpentine'.

plotNumber

Numeric vector with starting plot numbers per location, per rep, or per location-rep pair (all reps of the first location first). A vector of length l is interpreted as starts per location. By default plotNumber = 101.

repsStack

Option for horizontal or vertical layout By default repsStack = 'vertical'.

exptName

(optional) Name of experiment.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

locationNames

(optional) Name for each location.

repsExpt

(optional) Number of reps of experiment. By default repsExpt = 1.

random

Logical value to randomize treatments or not. By default random = TRUE.

data

(optional) Data frame with the labels of treatments.

nrows

(optional) Number of rows in the field.

ncols

(optional) Number of columns in the field.

year

(optional) Year recorded in the YEAR column of the field book. By default the current year.

plotIncrement

(optional) Positive whole-number increment between block starts. For example, plotNumber = 101, plotIncrement = 100 starts blocks at 101, 201, 301, and so on. Must be at least the number of plots per block, including filler positions. With one start per location, each additional rep starts b * plotIncrement plot numbers after the previous rep. Explicit starts per rep must reserve non-overlapping experiment ranges within each location. NULL (the default) keeps continuous numbering. Filler plots retain plot number zero; treatment randomization is unchanged.

Value

A list with five elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(RCBD_augmented, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

References

Federer, W. T. (1955). Experimental Design. Theory and Application. New York, USA. The Macmillan Company.

Examples

# Example 1: Generates an ARCBD with 6 blocks, 3 checks for each, and 50 treatments 
# in two locations.
ARCBD1 <- RCBD_augmented(lines = 50, checks = 3, b = 6, l = 2, 
                         planter = "cartesian", 
                         plotNumber = c(1,1001),
                         seed = 23, 
                         locationNames = c("FARGO", "MINOT"))
ARCBD1$infoDesign
ARCBD1$layoutRandom
ARCBD1$exptNames
ARCBD1$plotNumber
head(ARCBD1$fieldBook, 12)
                   
# Example 2: Generates an ARCBD with 17 blocks, 4 checks for each, and 350 treatments 
# in 3 locations.
# In this case, we show how to use the option data.
checks <- 4;
list_checks <- paste("CH", 1:checks, sep = "")
treatments <- paste("G", 5:354, sep = "")
treatment_list <- data.frame(list(ENTRY = 1:354, NAME = c(list_checks, treatments)))
head(treatment_list, 12)
ARCBD2 <- RCBD_augmented(lines = 350, checks = 4, b = 17, l = 3, 
                         planter = "serpentine", 
                         plotNumber = c(101,1001,2001), 
                         seed = 24, 
                         locationNames = LETTERS[1:3],
                         data = treatment_list)
ARCBD2$infoDesign
ARCBD2$layoutRandom
ARCBD2$exptNames
ARCBD2$plotNumber
head(ARCBD2$fieldBook, 12)
                                       
# Number blocks at 101, 201, ...; the second rep uses 601, 701, ...
ARCBD3 <- RCBD_augmented(lines = 50, checks = 3, b = 5, repsExpt = 2,
                         plotNumber = 101, plotIncrement = 100, seed = 23)
head(ARCBD3$fieldBook)


Generates an Alpha Design

Description

Randomly generates an alpha design like alpha(0,1) across multiple locations.

Usage

alpha_lattice(
  t = NULL,
  k = NULL,
  r = NULL,
  l = 1,
  plotNumber = 101,
  locationNames = NULL,
  seed = NULL,
  data = NULL,
  reps = NULL,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

t

Number of treatments, or a character vector with the treatment labels.

k

Size of incomplete blocks (number of units per incomplete block).

r

Deprecated alias for reps; positional calls remain supported.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

locationNames

(optional) String with names for each of the l locations.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

data

(optional) Data frame with label list of treatments.

reps

Number of full resolvable replicates per location.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the serpentine planting path of the whole field. See field_layout for how the design is placed.

stacked

How the replicates of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of replicates). It needs nrows or ncols. By default the arrangement whose replicate is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout.

Value

A list with two elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters, using reps for replication. Under the same package versions and RNG settings, rebuild a result x with do.call(alpha_lattice, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

Examples

# Example 1: Generates an alpha design with 4 full blocks and 15 treatments.
# Size of IBlocks k = 3.
alphalattice1 <- alpha_lattice(t = 15, 
                               k = 3, 
                               reps = 4,
                               l = 1, 
                               plotNumber = 101, 
                               locationNames = "GreenHouse", 
                               seed = 1247)
alphalattice1$infoDesign
head(alphalattice1$fieldBook, 10)

# Example 2: Generates an alpha design with 3 full blocks and 25 treatment.
# Size of IBlocks k = 5. 
# In this case, we show how to use the option data.
treatments <- paste("G-", 1:25, sep = "")
ENTRY <- 1:25
treatment_list <- data.frame(list(ENTRY = ENTRY, TREATMENT = treatments))
head(treatment_list) 
alphalattice2 <- alpha_lattice(t = 25,
                               k = 5,
                               reps = 3,
                               l = 1, 
                               plotNumber = 1001, 
                               locationNames = "A", 
                               seed = 1945,
                               data = treatment_list)
alphalattice2$infoDesign
head(alphalattice2$fieldBook, 10)


Augmented row-column design

Description

Arrange unreplicated test entries and k replicated checks in a complete rectangular field, so that every check appears exactly once in every field line along check_direction, and search the check positions for an efficient design under fixed row and column effects.

Usage

augmented_row_column(
  nrows,
  ncols,
  checks,
  check_direction,
  entries = NULL,
  objective = arc_design_defaults()$objective,
  method = "staged",
  budget = NULL,
  time_limit = NULL,
  l = 1,
  plotNumber = 101,
  planter = "serpentine",
  locationNames = NULL,
  exptName = NULL,
  year = NULL,
  seed = NULL,
  data = NULL
)

Arguments

nrows

Number of field rows, a whole number.

ncols

Number of field columns, a whole number.

checks

The checks: a whole-number count k >= 2, which gives the labels CH1, ..., CHk, or a character vector of at least two distinct, nonmissing, nonblank labels, used in that order. With data, it must be the count of checks.

check_direction

"columns" or "rows": the physical direction along which every check appears once per line. Required, with no default; it is never inferred from the field shape. With "columns", each check appears once in every field column, so v = nrows and s = ncols; with "rows", once in every field row, so v = ncols and s = nrows. The design needs s <= v.

entries

The test entries, excluding checks. NULL (default) fills every test plot, nrows * ncols - k * s of them, with the labels G(k+1), ..., G(k+n). A whole-number count must equal that number of test plots and gives the same labels. A character vector of distinct, nonmissing, nonblank labels must have that length. Must be NULL when data is given.

objective

The criterion the search optimizes: "V_tt" (minimize the mean variance of test-versus-test comparisons), "V_tc" (minimize the mean variance of test-versus-check comparisons) or "E_aug" (maximize the harmonic-mean efficiency of all treatment comparisons). The default is "V_tt". Pass objective explicitly when a result must be reproducible across package versions; reproduction code always states it.

method

Search method. Only "staged" (staged annealing with recolouring restarts) is available.

budget

Objective-function calls allowed per location, a positive whole number. NULL (default) uses 60,000 calls when v * s <= 600 and 100,000 above. Pass budget explicitly when a result must be reproducible across package versions. The recorded parameters keep the effective value.

time_limit

Optional per-location search cutoff, in seconds of wall-clock time, or NULL (default) for none. See "Search, budget and time limit" below.

l

Number of locations, each an independent run of the same search.

plotNumber

First plot number: one positive whole number, used at every location, or one per location.

planter

Plot-number path, "serpentine" or "cartesian".

locationNames

Distinct nonblank location labels, one per location; NULL gives 1, ..., l.

exptName

Experiment name recorded in the EXPT column; NULL gives "Expt1".

year

Year recorded in the YEAR column; NULL gives the current calendar year. The effective year is recorded, so a later replay reproduces it.

seed

Randomization seed; NULL draws and records one automatic seed.

data

Optional entry table with exactly the columns ENTRY and NAME, as in diagonal_arrangement(): the first checks rows are the checks and the remaining rows the tests. ENTRY holds distinct positive whole numbers and NAME distinct, nonblank text labels. It must have k rows plus one row per test plot.

Details

Construction. The design is a complete nrows x ncols field. Every test entry occupies one plot and every check occupies s plots: exactly one in each of the s field lines along check_direction. Along the v cross-lines, no check is repeated and every cross-line holds between floor(k * s / v) and ceiling(k * s / v) check plots, at least one. This is the restricted contraction construction of Piepho and Williams (2026); square fields (v = s) include the square-array designs of Bailey and Haines (2025). Field coordinates and plot numbers are fixed at construction.

Model and objectives. Under the additive model with fixed row, column and entry effects and independent errors, the residual degrees of freedom are k * s - k - v - s + 2. Fields with fewer than 1 are rejected. Fields with fewer than 10 raise a warning: only adding a check or changing the number of rows or columns raises them. E_aug, V_tt and V_tc are reported for every location, whichever is optimized.

Search, budget and time limit. FielDHub searches the check positions with staged annealing; the search is FielDHub's own method, not part of the published construction. Each location runs one search with its own seed (the recorded seed plus the location index minus one) and at most budget objective calls. time_limit, when given, bounds each location's search phase only: final verification, randomization and field-book assembly always run to completion, and with l locations the call can take about l * time_limit seconds plus that work. A location stopped by the time limit records time_limit_hit = TRUE in its diagnostics. A cutoff reached before the search has produced any design raises a fieldhub_arc_search_error, as does a search that finds no connected start; there is no silent fallback to another method.

Randomization. After the search, the field lines and cross-lines are permuted at random, the check labels receive one random permutation, and the tests are assigned to the test plots at random. None of these steps changes an objective. The returned contraction and statistics describe this final, randomized placement.

Value

A schema-1 FielDHub result with class fieldhub_augmented_row_column and the elements:

Reproducibility

reproduce_design(x) and do.call(augmented_row_column, x$metadata$parameters) replay the design from its recorded parameters. Replay is exact (identical field book, contraction, statistics, diagnostics and parameters; only timing and the recorded package version are excluded) for evaluation-budget runs that did not hit time_limit, within the same software and numerical environment: the same FielDHub and R versions, BLAS/LAPACK library and thread count, and platform. A time_limit cutoff makes replay timing-dependent. In a different environment, replay gives a valid design with comparable statistics, which may be a different design.

Standalone reproduction code is available for the standard entry template at any size, and for any upload up to 200 rows. An upload whose ENTRY values are exactly 1, ..., k + n in row order is recorded as its check and test labels, with data = NULL; other uploads are recorded as uploaded, and above 200 rows the reproduction code falls back to the saved result (RDS).

References

Piepho, H.-P., and Williams, E. R. (2026). Rectangular augmented row-column designs generated from contractions. Biometrical Journal, 68(5), e70182. doi:10.1002/bimj.70182

Bailey, R. A., and Haines, L. M. (2025). Square array designs for unreplicated test treatments with replicated controls. Journal of Agricultural, Biological and Environmental Statistics. doi:10.1007/s13253-025-00699-1

See Also

diagonal_arrangement, reproduce_design, design_arguments

Examples

# 4 checks and 48 tests in a 10 x 8 field; every check appears once in
# each field column. A small budget keeps the example fast.
x <- augmented_row_column(nrows = 10, ncols = 8, checks = 4,
                          check_direction = "columns", budget = 2000,
                          seed = 2026)
x$infoDesign$residual_df
x$statistics
head(x$fieldBook)
# Check plots per field column: each check once in every column
checks <- x$fieldBook[x$fieldBook$CHECKS > 0, ]
table(checks$TREATMENT, checks$COLUMN)

# The same field turned through 90 degrees, with labelled checks
y <- augmented_row_column(nrows = 8, ncols = 10,
                          checks = c("Check A", "Check B", "Check C",
                                     "Check D"),
                          check_direction = "rows", objective = "E_aug",
                          budget = 2000, seed = 7)
y$contraction

# Replay from the recorded parameters
identical(reproduce_design(x)$fieldBook, x$fieldBook)

Shared design arguments and compatibility

Description

Use named arguments when writing FielDHub scripts. The common names below describe the same concepts across the design families that support them. Each function's help page defines its supported inputs and constraints.

Common arguments

t

Treatments in classical designs: a count or, where supported, a vector of labels. Check-based designs use lines for the number of experimental entries excluding checks.

entries

Test entries excluding checks, as a count or as a vector of labels, in augmented_row_column(). It describes the same entries as lines in the other check-based designs, where lines is a count only; entries also accepts labels because an uploaded entry list is recorded portably as its labels.

reps

Full replicates per location in classical, incomplete-block, lattice, row-column and strip-plot designs. In latin_square(), this is the number of independent squares. Partial and multi-location replication uses the design-specific allocation arguments instead.

l

Number of locations. CRD() and latin_square() generate one location and have no l argument.

locationNames

Location labels, in location order. CRD() takes one location name.

plotNumber

Starting plot number, or one start per location.

seed

Seed recorded in the result to reproduce randomization. When seed is NULL, one integer is drawn from the current random-number stream and recorded; the design's own randomization does not change the caller's stream.

k

Number of plots per incomplete block.

checks

A check count, entry identifiers, or labels; see "Dimensions, factors and checks" below.

rep_checks

Check replication: how many times each check is repeated. RCBD() takes one count per check label supplied in checks (recycled from a scalar). optimized_arrangement() takes either a total check count or one count per check label (this is amountChecks in 1.5.x scripts; see "Migrating existing scripts"). Multi-location allocations (multi_location_prep(), do_optim(design = "prep")) take the same one-count-per-check form. sparse_allocation() and do_optim(design = "sparse") have no rep_checks: every check is replicated once per location by construction.

Dimensions, factors and checks

nrows and ncols describe field dimensions in spatial designs. In row_column(), nrows is the number of rows per replicate; field_layout() controls how replicates are placed in the field. Factorial, split-plot and strip-plot designs keep their factor-specific arguments so whole plots, subplots and crossed strips remain distinct. The meaning of checks is design-specific: a count, entry identifiers, or labels. Consult the function's help before transferring a check vector between design families.

Partial and multi-location replication does not share one argument name across families; each keeps the allocation arguments that describe its own replication scheme: partially_replicated()'s repGens (how many entries get each replication level) and repUnits (those replication levels), and RCBD_augmented()'s b (number of augmented blocks) and repsExpt (replicates of the whole experiment). These are design-specific allocation arguments, not aliases of reps or rep_checks.

Boolean controls

Logical switches such as continuous, factorLabels, spread_reps, allow_fillers, and randomizeH require one nonmissing TRUE or FALSE. Numeric switches (0/1), strings, vectors, and arrays are not supported. Invalid switches signal a fieldhub_input_error before randomization, with argument, value, and options fields identifying the correction.

Migrating existing scripts

CRD(locationName = ...) remains supported; use CRD(locationNames = ...) in new code. In incomplete_blocks(), alpha_lattice(), square_lattice(), rectangular_lattice() and row_column(), replace the argument name r with reps. In strip_plot(), replace b with reps. In optimized_arrangement(), replace amountChecks with rep_checks. RCBD_augmented(b = ...) still denotes blocks and is unchanged.

Old names and positional calls retain their meaning and signal a warning of class fieldhub_deprecated_warning. Supplying both names for one argument is an error, even if their values agree. These aliases do not change seeded designs or the field names of saved results.

See Also

CRD, incomplete_blocks, row_column, strip_plot, field_layout


Supported recorded-design file formats

Description

Lists the version and read/write capabilities of the built-in design format registry. Formats are selected explicitly, not guessed from filenames. CSV tables and app workflow ZIPs are separate exports; neither is silently interpreted as a complete recorded design by these functions.

Usage

design_formats()

Value

A data frame with format, extension, media_type, format_version, readable and writable columns.

Examples

design_formats()

Design results and reproducibility metadata

Description

FielDHub uses a versioned result contract. Schema 1 retains the established elements and storage types of each design family; validation checks those elements without coercing valid field books or removing user columns. Field, family, allocation and optimization results share the same construction boundary, with validation appropriate to each result type.

Field designs

Field designs inherit from FielDHub, with a first class such as fieldhub_rcbd identifying the engine. Test inheritance with inherits(x, "FielDHub"), not equality with class(x). Their fieldBook contains finite numeric ID and PLOT vectors and nonmissing atomic LOCATION identifiers. Integer and double storage, factors, and the existing character or numeric location conventions are preserved rather than normalized.

Additional required columns depend on the design:

Required extension columns are atomic vectors, not matrix or list columns. Numeric values must be finite. Missing CHECKS values remain supported, as do missing REP values on partially replicated filler plots with ENTRY = 0. Other required extension values cannot be missing. Extra columns are permitted. Use field_layout() to obtain the final coordinates and plot numbers for a chosen planting path and layout.

Family splits and allocation plans

split_families() returns rowsEachlist with location counts and data_locations with ENTRY, NAME, FAMILY and LOCATION. Counts must agree with the entry table, including locations with zero entries.

do_optim() retains the Sparse or MultiPrep class. Its allocation counts, location sizes and entry lists are validated; these plans are not field books and do not yet specify plot coordinates.

Standalone optimization

swap_pairs() retains its matrices, distances and stopping diagnostics, with the classes fieldhub_pair_swap and fieldhub_optimization. Its shared metadata includes the input matrix and every optimization control. The validator checks field geometry, entry counts and retained search steps. These results can be saved and replayed with reproduce_design().

Reproducibility

metadata records design, schema_version, seed, rng_kind, package_version and, in newly generated results, parameters. Parameters use effective values after validation, including defaults, the resolved year and seed, and uploaded data. Automatic seeds are integers; explicit real-valued seeds retain the legacy behavior of R's set.seed(), which truncates to an integer.

Use saveRDS() and readRDS() to retain the exact result and its metadata, then reproduce_design() to reconstruct it. Exact replay of optimization may require the same dependency versions and platform. Layout selections and simulated responses added later by the app are not part of the core design parameters.

Older schema-1 metadata without parameters still validates, but cannot be replayed automatically. Objects saved by FielDHub 1.5.0 without metadata remain supported by the print, summary and plotting compatibility methods; they are not silently rewritten to the new schema.

See Also

reproduce_design, field_layout, design_arguments


Spatial Un-replicated Diagonal Arrangement Design

Description

Randomly generates an spatial un-replicated diagonal arrangement design.

Usage

diagonal_arrangement(
  nrows = NULL,
  ncols = NULL,
  lines = NULL,
  checks = NULL,
  planter = "serpentine",
  l = 1,
  plotNumber = 101,
  kindExpt = "SUDC",
  splitBy = "row",
  seed = NULL,
  blocks = NULL,
  exptName = NULL,
  locationNames = NULL,
  multiLocationData = FALSE,
  data = NULL,
  year = NULL,
  checksPercent = NULL,
  sameEntries = FALSE,
  spread_checks = FALSE,
  dist_method = "euclidean"
)

Arguments

nrows

Number of rows in the field.

ncols

Number of columns in the field.

lines

Number of genotypes, experimental lines or treatments.

checks

Number of genotypes checks, or a vector of their entry numbers (distinct consecutive whole numbers in increasing order, e.g. c(301, 302)).

planter

Option for serpentine or cartesian plot arrangement. By default planter = 'serpentine'.

l

Number of locations or sites. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

kindExpt

Type of diagonal design, with single options: Single Un-replicated Diagonal Checks 'SUDC' and Decision Blocks Un-replicated Design with Diagonal Checks 'DBUDC' for multiple experiments. By default kindExpt = 'SUDC'.

splitBy

Option to split the field when kindExpt = 'DBUDC' is selected. By default splitBy = 'row'.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

blocks

Number of experiments or blocks to generate an DBUDC design. If kindExpt = 'DBUDC' and data is null, blocks are mandatory.

exptName

(optional) Name of the experiment.

locationNames

(optional) Names each location.

multiLocationData

(optional) Option to pass an entry list for multiple locations. By default multiLocationData = FALSE.

data

(optional) Data frame with 2 columns: ENTRY | NAME .

year

(optional) Year recorded in the YEAR column of the field book. By default the current year.

checksPercent

(optional) Percentage of checks, one of the options available for the field dimensions. By default the last (largest) option.

sameEntries

(optional) Logical. When TRUE and kindExpt = "DBUDC", every block holds the same entries, and all blocks must have the same size. By default sameEntries = FALSE.

spread_checks

Logical. Exchange check identities among the existing check plots of each location to increase separation of repeated checks, for kindExpt = "SUDC" and "DBUDC". Test entries, filler plots, the check plots themselves, the experiments (blocks) and each check's replication in the location stay fixed. The default FALSE preserves the original randomization.

dist_method

Distance between field coordinates for check optimization: "euclidean" (default) or "manhattan". Grid steps have equal scale.

Details

Check optimization compares counts of same-check pairs at ascending distances, reducing the count at the shortest differing distance first. It is a deterministic local exchange heuristic, not a statistical-efficiency or global-optimality guarantee. Each location stops after a complete scan finds no improvement, 100 accepted swaps, or 100,000 candidate evaluations. One check identity, or checks occurring only once, leaves the layout unchanged. With kindExpt = "DBUDC" identities are exchanged across the whole field of a location, as for a single arrangement: the entries and the plots of every experiment stay where they are. The selected check percentage and filler count are unchanged. With checksPercent = NULL, Single Diagonal Arrangement still selects the valid option with the most check plots and therefore the fewest fillers.

Value

A FielDHub design result with the following components.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(diagonal_arrangement, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

References

Clarke, G. P. Y., & Stefanova, K. T. (2011). Optimal design for early-generation plant breeding trials with unreplicated or partially replicated test lines. Australian & New Zealand Journal of Statistics, 53(4), 461–480.

Examples


# Example 1: Generates a spatial single diagonal arrangement design in one location
# with 270 treatments and 30 check plots for a field with dimensions 15 rows x 20 cols
# in a serpentine arrangement.
spatd <- diagonal_arrangement(
  nrows = 15, 
  ncols = 20, 
  lines = 270, 
  checks = 4, 
  plotNumber = 101, 
  kindExpt = "SUDC", 
  planter = "serpentine", 
  seed = 1987,
  exptName = "20WRY1", 
  locationNames = "MINOT"
)
spatd$infoDesign
# Optimize check identities while keeping the diagonal check plots fixed.
spread <- diagonal_arrangement(nrows = 15, ncols = 20, lines = 270, checks = 4,
                               seed = 1987, spread_checks = TRUE)
spread$infoDesign$check_optimization
spatd$layoutRandom
spatd$plotsNumber
head(spatd$fieldBook, 12)

# Example 2: Generates a spatial decision block diagonal arrangement design in one location
# with 720 treatments allocated in 5 experiments or blocks for a field with dimensions
# 30 rows x 26 cols in a serpentine arrangement. In this case, we show how to set up the data 
# option with the entries list.
checks <- 5;expts <- 5
list_checks <- paste("CH", 1:checks, sep = "")
treatments <- paste("G", 6:725, sep = "")
treatment_list <- data.frame(list(ENTRY = 1:725, NAME = c(list_checks, treatments)))
head(treatment_list, 12) 
tail(treatment_list, 12)
spatDB <- diagonal_arrangement(
  nrows = 30, 
  ncols = 26,
  checks = 5, 
  plotNumber = 1, 
  kindExpt = "DBUDC", 
  planter = "serpentine", 
  splitBy = "row", 
  blocks = c(150,155,95,200,120),
  data = treatment_list
)
spatDB$infoDesign
spatDB$layoutRandom
spatDB$plotsNumber
head(spatDB$fieldBook,12)

# Example 3: Generates a spatial decision block diagonal arrangement design in one location
# with 270 treatments allocated in 3 experiments or blocks for a field with dimensions
# 20 rows x 15 cols in a serpentine arrangement. Which in turn is an augmented block (3 blocks).
spatAB <- diagonal_arrangement(
  nrows = 20, 
  ncols = 15, 
  lines = 270, 
  checks = 4, 
  plotNumber = c(1,1001,2001), 
  kindExpt = "DBUDC", 
  planter = "serpentine",
  exptName = c("20WRA", "20WRB", "20WRC"), 
  blocks = c(90, 90, 90),
  splitBy = "column"
)
spatAB$infoDesign
spatAB$layoutRandom
spatAB$plotsNumber
head(spatAB$fieldBook,12)


Generate the sparse or p-rep allocation to multiple locations.

Description

Generate the sparse or p-rep allocation to multiple locations.

Usage

do_optim(
  design = "sparse",
  lines,
  l,
  copies_per_entry,
  add_checks = FALSE,
  checks = NULL,
  rep_checks = NULL,
  force_balance = TRUE,
  seed,
  data = NULL
)

Arguments

design

Type of experimental design. It can be prep or sparse

lines

Number of genotypes, experimental lines or treatments.

l

Number of locations or sites. By default l = 1.

copies_per_entry

Number of copies per plant. When design is sparse then copies_per_entry should be less than l

add_checks

Option to add checks. Optional if design = "prep"

checks

Number of genotypes checks.

rep_checks

Replication for each check.

force_balance

Get balanced unbalanced locations. By default force_balance = TRUE.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

data

(optional) Data frame with 2 columns: ENTRY | NAME . ENTRY must be numeric.

Details

The entry copies are allocated to the locations by FielDHub's own compiled block-design search: D-optimal plot swaps after Edmondson (2020), 20 searches from random starts drawn with the seed (the first starts from a square lattice when the shape is one). Every allocation is even: each entry has floor(copies_per_entry / l) or one more copies at each location (a final even-up step guarantees it), and location totals differ by at most one copy before force_balance. One location takes every copy without a search. From FielDHub 1.7.0 this search replaces blocksdesign::blocks(), so allocations for a given seed differ from earlier versions.

The swap search stops after at most 60 seconds; the even-up step and the final scoring run after it, outside that limit. A run stopped by the limit warns, records stop_reason = "time_limit", and may not be reproducible from its seed, because where it stopped depends on the machine's speed.

Value

A list with five elements, classed c("fieldhub_sparse_optimization", "Sparse") or c("fieldhub_multi_prep_optimization", "MultiPrep"): the legacy Sparse/MultiPrep class is retained for compatibility, with an additional fieldhub_* class alongside it.

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb]

References

Edmondson, R.N. Multi-level Block Designs for Comparative Experiments. JABES 25, 500–522 (2020). https://doi.org/10.1007/s13253-020-00416-0

Examples

sparse_example <- do_optim(
   design = "sparse",
   lines = 120,
   l = 4,
   copies_per_entry = 3,
   add_checks = TRUE,
   checks = 4,
   seed = 15
)

Field layout of a design

Description

Returns the field book of a design with the ROW and COLUMN of every plot, for the layout, planter and stacking chosen. This is the field book that plot() draws and that the app exports.

The field books of CRD(), RCBD(), latin_square(), full_factorial(), split_plot(), split_split_plot(), strip_plot(), incomplete_blocks(), row_column() and the lattice designs have no field coordinates by default: their plots can be arranged in several ways, and the layouts that renumber the plots along the planting path also change PLOT. The other designs place their plots when they are built; their field book already has ROW and COLUMN, and it is returned as it is. The physical layout of a resolvable row-column design retains the experimental axes as ROW_REP and COLUMN_REP.

With nrows or ncols, the design is placed in a field of those dimensions instead of a numbered layout. Each location must have exactly as many cells as plots, including repeated checks, and the units of the design are equal rectangles of the field:

The plots are then numbered along the planting path of the whole field, serpentine or cartesian as planter says, as in the numbered layouts: the plot numbers of the location are handed out in increasing order as the planter reaches each plot, and the path does not restart in each block or replicate. With a serpentine planter, consecutive plot numbers are therefore neighbours in the field. Subplots that share a plot number keep sharing one; whole plots that tile the field as equal rectangles are numbered along the planter's path over the grid of whole plots, so consecutive whole plots are neighbours too. The randomization does not change: every row of the field book keeps its treatment, replicate and block, and only PLOT differs from the design's own field book. Where the plot numbers restart at each replicate (101, 201, ...), the hundreds name the replicate only where the replicates lie one above the other.

In a field of given dimensions, stacked arranges the replicates: the complete blocks of an RCBD or of a factorial in blocks, the replicates of split, split-split and strip plots, of incomplete blocks and of the lattices, and the squares of a Latin square.

When stacked is not given with dimensions, the stacking is the one whose replicate is the most square (the smallest difference between its rows and its columns) among those that fit the dimensions; this also chooses among the panels of "grid_panel". A tie goes to "vertical", then to "horizontal", then to the panel with the most rows of replicates. CRD, and factorials and split plots in CRD, have no replicates to stack: stacked with their dimensions is an error.

Dimensions that do not fit, or do not fit the stacking asked for, are an error that suggests dimensions that do. layout selects a numbered layout: giving it together with dimensions is an error.

A design built with dimensions (RCBD(..., nrows = 4)) has one layout: the grid stored in its field book, numbered along the path of the planter it was built with, its replicates stacked as its metadata$parameters$stacked records. field_layout() returns that field book when it is called with no other argument, or with the same planter, stacked or dimensions. Another planter, another stacked or other dimensions are an error: for another layout, build the design again with other dimensions or another stacking, or without dimensions.

Usage

field_layout(
  x,
  layout = 1,
  planter = "serpentine",
  stacked = "vertical",
  nrows = NULL,
  ncols = NULL
)

Arguments

x

A design created by a FielDHub function.

layout

Layout option, a whole number. The options depend on the design, the planter and the stacking; an unavailable option is an error that lists the available ones.

planter

Order in which the plots are planted: "serpentine" (by default) or "cartesian".

stacked

How the reps are arranged: "vertical" (by default), "horizontal", or "grid_panel" for designs in incomplete blocks and split plots in complete blocks with more than two reps. With nrows or ncols it arranges the replicates in the field of those dimensions, for every design with replicates, and its default is the stacking whose replicate is the most square (see the description).

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location, for the designs listed above. If only one is given, the other follows from the number of plots.

Value

A data frame: the field book of every location with the columns ID, LOCATION, PLOT, ROW and COLUMN first.

Author(s)

Didier Murillo [aut]

Examples

rcbd <- RCBD(t = 6, reps = 3, plotNumber = 101, seed = 1)
head(field_layout(rcbd))
# Blocks side by side, plots planted row by row
head(field_layout(rcbd, stacked = "horizontal", planter = "cartesian"))
# Six complete blocks arranged two down and three across in a field of
# 4 rows and 9 columns, numbered along the serpentine path of the field
head(field_layout(RCBD(t = 6, reps = 6, seed = 1), nrows = 4, ncols = 9))
# Four blocks of 1 x 6 plots one above another, or 2 x 3 blocks in a panel
# of two by two, in the same field of 4 rows and 6 columns
blocks <- RCBD(t = 6, reps = 4, seed = 1)
head(field_layout(blocks, stacked = "vertical", nrows = 4, ncols = 6))
head(field_layout(blocks, stacked = "grid_panel", nrows = 4, ncols = 6))


Generates a Full Factorial Design

Description

It randomly generates a full factorial design across locations.

Usage

full_factorial(
  setfactors = NULL,
  reps = NULL,
  l = 1,
  type = 2,
  plotNumber = 101,
  continuous = FALSE,
  planter = "serpentine",
  seed = NULL,
  locationNames = NULL,
  factorLabels = TRUE,
  data = NULL,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

setfactors

Numeric vector with levels of each factor.

reps

Number of replicates (full blocks).

l

Number of locations. By default l = 1.

type

Option for CRD or RCBD designs. Values are type = 1 (CRD) or type = 2 (RCBD). By default type = 2.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

continuous

Logical for plot number continuous or not. By default continuous = FALSE.

planter

Option for serpentine or cartesian plot arrangement. By default planter = 'serpentine'.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

locationNames

(optional) Names for each location.

factorLabels

(optional) If TRUE retain the levels labels from the original data set otherwise, numeric labels will be assigned. Default is factorLabels =TRUE.

data

(optional) Data frame whose first two columns contain factor names and level labels. Levels must be unique within each factor, but a label may occur in different factors. Incomplete rows are omitted.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the planting path of the whole field (see planter). See field_layout for how the design is placed.

stacked

How the replicates of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of replicates). It needs nrows or ncols. By default the arrangement whose replicate is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout. An error for type = 1, which has no replicates to stack.

Value

A list with two elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(full_factorial, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

References

Federer, W. T. (1955). Experimental Design. Theory and Application. New York, USA. The Macmillan Company.

Examples

# Example 1: Generates a full factorial with 3 factors each with 2 levels.
# This in an RCBD arrangement with 3 reps.
fullFact1 <- full_factorial(setfactors = c(2,2,2), reps = 3, l = 1, type = 2,
                            plotNumber = 101,
                            continuous = TRUE,
                            planter = "serpentine",
                            seed = 325,
                            locationNames = "FARGO")
fullFact1$infoDesign
head(fullFact1$fieldBook,10)

# Example 2: Generates a full factorial with 3 factors and each with levels: 2,3,
# and 2, respectively. In this case, we show how to use the option data
FACTORS <- rep(c("A", "B", "C"), c(2,3,2))
LEVELS <- c("a0", "a1", "b0", "b1", "b2", "c0", "c1")
data_factorial <- data.frame(list(FACTOR = FACTORS, LEVEL = LEVELS))
print(data_factorial)
# This in an RCBD arrangement with 5 reps in 3 locations.
fullFact2 <- full_factorial(setfactors = NULL, reps = 5, l = 3, type = 2,
                            plotNumber = c(101,1001,2001),
                            continuous = FALSE,
                            planter = "serpentine",
                            seed = 326,
                            locationNames = c("Loc1","Loc2","Loc3"),
                            data = data_factorial)
fullFact2$infoDesign
head(fullFact2$fieldBook,10)


Generates a Resolvable Incomplete Block Design

Description

Randomly generates a resolvable incomplete block design (IBD) of characteristics (t, k, r). The randomization can be done across locations.

Usage

incomplete_blocks(
  t = NULL,
  k = NULL,
  r = NULL,
  l = 1,
  plotNumber = 101,
  locationNames = NULL,
  seed = NULL,
  data = NULL,
  reps = NULL,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

t

Number of treatments, or a character vector with the treatment labels.

k

Size of incomplete blocks (number of units per incomplete block).

r

Deprecated alias for reps; positional calls remain supported.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

locationNames

(optional) Names for each location.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

data

(optional) Data frame with label list of treatments.

reps

Number of full resolvable replicates per location.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the serpentine planting path of the whole field. See field_layout for how the design is placed.

stacked

How the replicates of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of replicates). It needs nrows or ncols. By default the arrangement whose replicate is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout.

Value

A list with two elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters, using reps for replication. Under the same package versions and RNG settings, rebuild a result x with do.call(incomplete_blocks, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

Examples

# Example 1: Generates a resolvable IBD of characteristics (t,k,r) = (12,4,2).
# 1-resolvable IBDs
ibd1 <- incomplete_blocks(t = 12,
                          k = 4,
                          reps = 2,
                          seed = 1984)
ibd1$infoDesign
head(ibd1$fieldBook)

# Example 2: Generates a balanced resolvable IBD of characteristics (t,k,r) = (15,3,7).
# In this case, we show how to use the option data.
treatments <- paste("TX-", 1:15, sep = "")
ENTRY <- 1:15
treatment_list <- data.frame(list(ENTRY = ENTRY, TREATMENT = treatments))
head(treatment_list)
ibd2 <- incomplete_blocks(t = 15,
                          k = 3,
                          reps = 7,
                          seed = 1985,
                          data = treatment_list)
ibd2$infoDesign
head(ibd2$fieldBook)


Randomized cyclic Latin rectangle

Description

Arrange treatments in fewer complete rows than a Latin square, with no treatment repeated in any column. Each row is a complete replicate.

Usage

latin_rectangle(
  t,
  rows = 3,
  l = 1,
  plotNumber = 101,
  planter = "serpentine",
  seed = NULL,
  locationNames = NULL
)

Arguments

t

Number of treatments (at least two), or distinct character labels.

rows

Number of complete rows, from two through the treatment count.

l

Number of independently randomized locations.

plotNumber

First plot number: one positive whole number, or one per location. Plot numbers restart at the supplied value for each location.

planter

Plot-number traversal, "serpentine" or "cartesian".

seed

Randomization seed; NULL draws and records one automatic seed.

locationNames

Distinct nonblank location labels, one per location; NULL generates LOC1, LOC2, and so on. Labels are preserved.

Details

The construction takes the first rows consecutive shifts of the cyclic Latin square, then independently permutes rows, columns and treatment labels at each location. It samples this cyclic construction family, not uniformly from all Latin rectangles, and does not optimize efficiency. It uses O(l * rows * t) construction work with no search.

Rows are complete blocks; columns are incomplete when rows < t. This is not necessarily a balanced incomplete-block or Youden design. Consecutive cyclic shifts keep the additive row/column/treatment model connected. Its residual degrees of freedom at one location are (rows - 2) * (t - 1): two-row rectangles are saturated and cannot independently estimate residual variation under that model. Interactions are not separately estimable. Choose replication and analysis with the intended scientific use in mind.

Field coordinates and plot numbering are fixed at construction. The planter and stacked arguments to field_layout() do not rearrange a saved rectangle. Supplied seeds preserve the caller's RNG; an automatic seed consumes exactly one recorded draw.

Value

A schema-1 FielDHub result with infoDesign, a field book containing ID, LOCATION, PLOT, ROW, COLUMN, REP and TREATMENT, and replay metadata. REP is the complete row block. Use reproduce_design() for replay and field_layout() for the recorded coordinates.

References

Peter G. Doyle, The number of Latin rectangles. https://math.dartmouth.edu/~doyle/docs/latin/latin.pdf.

Examples

x <- latin_rectangle(t = 5, rows = 3, seed = 27)
x$fieldBook
identical(reproduce_design(x), x)

Generates a Latin Square Design

Description

Randomly generates a latin square design of up 10 treatments.

Usage

latin_square(
  t = NULL,
  reps = 1,
  plotNumber = 101,
  planter = "serpentine",
  seed = NULL,
  locationNames = NULL,
  data = NULL,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

t

Number of treatments.

reps

Number of full resolvable squares. By default reps = 1.

plotNumber

Starting plot number. By default plotNumber = 101.

planter

Option for serpentine or cartesian arrangement. By default planter = 'serpentine'.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

locationNames

(optional) Name for the location.

data

(optional) Data frame with label list of treatments.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the planting path of the whole field (see planter). See field_layout for how the design is placed.

stacked

How the squares of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of squares). It needs nrows or ncols. By default the arrangement whose square is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout.

Details

The randomized search is limited to 100,000 placement iterations per square. If it cannot complete a square within that budget, it raises a fieldhub_search_error with the square number and iteration limit. No incomplete design is returned; try a different seed. Designs completed within the limit retain their existing seeded output.

Value

A list with information on the design parameters.

Data frame with the latin square field book.

A list with two elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(latin_square, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Thiago de Paula Oliveira[ctb] Richard Horsley [ctb]

References

Federer, W. T. (1955). Experimental Design. Theory and Application. New York, USA. The Macmillan Company.

Examples

# Example 1: Generates a latin square design with 4 treatments and 2 reps.
latinSq1 <- latin_square(t = 4,
                         reps = 2,
                         plotNumber = 101,
                         planter = "cartesian",
                         seed = 1980)
print(latinSq1)
summary(latinSq1)
head(latinSq1$fieldBook)

# Example 2: Generates a latin square design with 5 treatments and 3 reps.
latin_data <- data.frame(list(ROW = paste("Period", 1:5, sep = ""),
                              COLUMN = paste("Cow", 1:5, sep = ""),
                              TREATMENT = paste("Diet", 1:5, sep = "")))
print(latin_data)
latinSq2 <- latin_square(t = NULL,
                         reps = 3,
                         plotNumber = 101,
                         planter = "cartesian",
                         seed = 1981,
                         data = latin_data)
latinSq2$squares
latinSq2$plotSquares
head(latinSq2$fieldBook)


Optimized multi-location partially replicated design

Description

Optimized multi-location partially replicated design

Usage

multi_location_prep(
  lines,
  nrows,
  ncols,
  l,
  planter = "serpentine",
  plotNumber,
  desired_avg,
  copies_per_entry,
  checks = NULL,
  rep_checks = NULL,
  exptName,
  locationNames,
  optim_list,
  seed,
  spread_reps = TRUE,
  data = NULL,
  allow_fillers = FALSE,
  max_fillers = NULL,
  year = NULL,
  rowcol_penalty = 0,
  rowcol_scope = "pairs"
)

Arguments

lines

Number of genotypes, experimental lines or treatments.

nrows

Numeric vector with the number of rows field at each location.

ncols

Numeric vector with the number of columns field at each location.

l

Number of locations. By default l = 1.

planter

Option for serpentine or cartesian movement. By default planter = 'serpentine'.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

desired_avg

(optional) Desired average of treatments across locations.

copies_per_entry

Number of total copies per treatment.

checks

Number of checks.

rep_checks

Number of replications per check.

exptName

(optional) Name of the experiment.

locationNames

(optional) Name for each location.

optim_list

(optional) A list object of class "MultiPrep"generated by do_optim() function.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

spread_reps

A logical value indicating whether to maximize the spatial distance between replicated treatments in the field. Default is TRUE.

data

(optional) Data frame with 2 columns: ENTRY | NAME . ENTRY must be numeric.

allow_fillers

A logical value indicating whether field dimensions may exceed the number of experimental plots. Fillers occupy the terminal cells of the selected planter path. Default is FALSE.

max_fillers

Maximum number of filler plots considered when dimensions are selected automatically. When NULL, up to 10 filler plots are considered.

year

(optional) Year recorded in the YEAR column of the field book. By default the current year.

rowcol_penalty

Weight of the rule that keeps the copies of a replicated entry in distinct rows and columns (Williams et al., 2011; Cullis et al., 2006); see swap_pairs. The default 0 leaves every layout unchanged; Inf puts distinct rows and columns first. With the rule on, infoDesign$shared_pairs gives the pairs of copies that still share a row or column at each location. Turning it on changes the optimizer's random draws, so with several locations the later locations' layouts change as well. It needs spread_reps = TRUE.

rowcol_scope

"pairs" (default) covers the entries with exactly two copies; "all" also covers the checks and any entry with more copies.

Details

The allocation of entries to locations comes from do_optim(); see its Details for the search, and for allocations that changed in FielDHub 1.7.0.

Value

A list of class FielDHub with several elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(multi_location_prep, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Jean-Marc Montpetit [ctb], Ana Heilman [ctb]

References

Williams, E., Piepho, H.-P., & Whitaker, D. (2011). Augmented p-rep designs. Biometrical Journal, 53(1), 19-27. https://doi.org/10.1002/bimj.201000102

Cullis, B. R., Smith, A. B., & Coombes, N. E. (2006). On the design of early generation variety trials with correlated data. Journal of Agricultural, Biological, and Environmental Statistics, 11, 381-393. https://doi.org/10.1198/108571106X154443

Edmondson, R.N. Multi-level Block Designs for Comparative Experiments. JABES 25, 500–522 (2020). https://doi.org/10.1007/s13253-020-00416-0

Examples

# Example 1: Generates a spatially optimized multi-location p-rep design with 142
# genotypes. The number of copies per plant available for this experiment is 9.
# This experiment is carried out in 5 locations, and there are seven seeds available
# for each plant to make replications.
# In this case, we add three controls (checks) with six reps each.
# With this setup, the experiment will have 142 treatments + 3 checks = 145
# entries and the number of plots per location after the allocation process
# will be 196.
# The average genotype allocation will be 1.5 copies per location.
## Not run: 
optim_multi_prep <- multi_location_prep(
  lines = 150,
  l = 5,
  copies_per_entry = 7,
  checks = 3,
  rep_checks = c(6,6,6),
  locationNames = c("LOC1", "LOC2", "LOC3", "LOC4", "LOC5"),
  seed = 1234
)
field_book <- optim_multi_prep$fieldBook
head(subset(field_book, LOCATION == "LOC1"), 10)

## End(Not run)

Generates an Spatial Un-replicated Optimized Arrangement Design

Description

Randomly generates a spatial un-replicated optimized arrangement design, where the distance between checks is maximized in such a way that each row and column have control plots. Note that design generation needs the dimension of the field (number of rows and columns).

Usage

optimized_arrangement(
  nrows = NULL,
  ncols = NULL,
  lines = NULL,
  amountChecks = NULL,
  checks = NULL,
  planter = "serpentine",
  l = 1,
  plotNumber = 101,
  seed = NULL,
  exptName = NULL,
  locationNames = NULL,
  spread_reps = TRUE,
  data = NULL,
  year = NULL,
  rep_checks = NULL
)

Arguments

nrows

Number of rows in the field.

ncols

Number of columns in the field.

lines

Number of genotypes, experimental lines or treatments.

amountChecks

Deprecated alias for rep_checks.

checks

Number of genotypes as checks.

planter

Option for serpentine or cartesian arrangement. By default planter = 'serpentine'.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

exptName

(optional) Name of the experiment.

locationNames

(optional) Name for each location.

spread_reps

A logical value indicating whether to maximize the spatial distance between replicated treatments in the field. Default is TRUE.

data

(optional) Data frame with 3 columns: ENTRY | NAME | REPS.

year

(optional) Year recorded in the YEAR column of the field book. By default the current year.

rep_checks

Integer with the total amount of checks, or a numeric vector with the replicates of each check label.

Value

A list with five elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(optimized_arrangement, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

References

Clarke, G. P. Y., & Stefanova, K. T. (2011). Optimal design for early-generation plant breeding trials with unreplicated or partially replicated test lines. Australian & New Zealand Journal of Statistics, 53(4), 461–480.

Examples

# Example 1: Generates a spatial unreplicated optimized arrangement design in one location
# with 120 genotypes + 20 check plots (4 checks) for a field with dimension 14 rows x 10 cols.
## Not run: 
optim_unrep1 <- optimized_arrangement(
  nrows = 14, 
  ncols = 10, 
  lines = 120,
  rep_checks = 20,
  checks = 1:4,
  planter = "cartesian", 
  plotNumber = 101,
  exptName = "20RW1",
  locationNames = "CASSELTON",
  seed = 14124
)
optim_unrep1$infoDesign
optim_unrep1$layoutRandom
optim_unrep1$plotNumber
head(optim_unrep1$fieldBook, 12)

## End(Not run)
                  
# Example 2: Generates a spatial unreplicated optimized arrangement design in one location
# with 200 genotypes + 20 check plots (4 checks) for a field with dimension 10 rows x 22 cols.
# As example, we set up the data option with the entries list.
## Not run: 
checks <- 4
list_checks <- paste("CH", 1:checks, sep = "")
treatments <- paste("G", 5:204, sep = "")
REPS <- c(5, 5, 5, 5, rep(1, 200))
treatment_list <- data.frame(list(ENTRY = 1:204, NAME = c(list_checks, treatments), REPS = REPS))
head(treatment_list, 12) 
tail(treatment_list, 12)
optim_unrep2 <- optimized_arrangement(
  nrows = 10, 
  ncols = 22, 
  planter = "serpentine", 
  plotNumber = 101,
  seed = 120,
  exptName = "20YWA2",
  locationNames = "MINOT",
  data = treatment_list
)
optim_unrep2$infoDesign
optim_unrep2$layoutRandom
optim_unrep2$plotNumber
head(optim_unrep2$fieldBook,12)

## End(Not run)
                  

Generates a Spatial Partially Replicated Arrangement Design

Description

Randomly generates a spatial partially replicated (p-rep) design for single or multiple locations.

Usage

partially_replicated(
  nrows = NULL,
  ncols = NULL,
  repGens = NULL,
  repUnits = NULL,
  planter = "serpentine",
  l = 1,
  plotNumber = 101,
  spread_reps = TRUE,
  seed = NULL,
  exptName = NULL,
  locationNames = NULL,
  multiLocationData = FALSE,
  dist_method = "euclidean",
  border_penalization = 0.5,
  data = NULL,
  allow_fillers = FALSE,
  year = NULL,
  rowcol_penalty = 0,
  rowcol_scope = "pairs"
)

Arguments

nrows

Numeric vector with the number of rows field at each location.

ncols

Numeric vector with the number of columns field at each location.

repGens

Numeric vector with the amount genotypes to replicate.

repUnits

Numeric vector with the number of reps of each genotype.

planter

Option for serpentine or cartesian movement. By default planter = 'serpentine'.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

spread_reps

A logical value indicating whether to maximize the spatial distance between replicated treatments in the field. Default is TRUE.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

exptName

(optional) Name of the experiment.

locationNames

(optional) Name for each location.

multiLocationData

(optional) Option to pass an entry list for multiple locations.

dist_method

The method used for distance calculation. Options are "euclidean" (default) and "manhattan". By default multiLocationData = FALSE.

border_penalization

A tuning parameter for the centrality penalty. Default is 0.5.

data

(optional) Data frame with 3 columns: ENTRY | NAME | REPS. If multiLocationData = TRUE then the data must have 4 columns: LOCATION | ENTRY | NAME | REPS

allow_fillers

A logical value indicating whether field dimensions may exceed the number of experimental plots. Fillers occupy the terminal cells of the selected planter path. Default is FALSE.

year

(optional) Year recorded in the YEAR column of the field book. By default the current year.

rowcol_penalty

Weight of the rule that keeps the copies of a replicated entry in distinct rows and columns (Williams et al., 2011; Cullis et al., 2006); see swap_pairs. The default 0 leaves every layout unchanged; Inf puts distinct rows and columns first. With the rule on, infoDesign$shared_pairs gives the pairs of copies that still share a row or column at each location. Turning it on changes the optimizer's random draws, so with several locations the later locations' layouts change as well. It needs spread_reps = TRUE.

rowcol_scope

"pairs" (default) covers the entries with exactly two copies; "all" also covers the checks and any entry with more copies.

Details

This function generates and optimizes a partially replicated (p-rep) experimental design for a given set of treatments and replication levels. The design is represented by a matrix and optimized using a pairwise distance metric. The function outputs various information about the optimized design including the field layout, replicated and unreplicated treatments, and pairwise distances between treatments. Note that the design generation needs the dimension of the field (number of rows and columns).

Value

A list with several elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(partially_replicated, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Jean-Marc Montpetit [ctb], Richard Horsley [ctb]

References

Williams, E., Piepho, H.-P., & Whitaker, D. (2011). Augmented p-rep designs. Biometrical Journal, 53(1), 19-27. https://doi.org/10.1002/bimj.201000102

Cullis, B. R., Smith, A. B., & Coombes, N. E. (2006). On the design of early generation variety trials with correlated data. Journal of Agricultural, Biological, and Environmental Statistics, 11, 381–393. https://doi.org/10.1198/108571106X154443

Examples

# Example 1: Generates a spatial optimized partially replicated arrangement design in one 
# location with 335 genotypes for a field with dimensions 15 rows x 28 cols. 
# Note that there are 250 genotypes unreplicated (only one time), 85 genotypes replicated 
# two times, and three checks 8 times each.
## Not run: 
prep_deseign1 <- partially_replicated(
 nrows = 12, 
 ncols = 37,  
 repGens = c(250, 85, 3),
 repUnits = c(1, 2, 8),
 planter = "cartesian", 
 plotNumber = 101,
 seed = 77
)
prep_deseign1$infoDesign
prep_deseign1$layoutRandom
prep_deseign1$plotNumber
head(prep_deseign1$fieldBook, 12)

## End(Not run)

# Example 2: Generates a spatial optimized partially replicated arrangement design with 492 
# genotypes in a field with dimensions 30 rows x 20 cols. Note that there 384 genotypes 
# unreplicated (only one time), 108 genotypes replicated two times. 
# In this case we don't have check plots.
# As example, we set up the data option with the entries list.
## Not run: 
NAME <- paste("G", 1:492, sep = "")
repGens = c(108, 384);repUnits = c(2,1)
REPS <- rep(repUnits, repGens)
treatment_list <- data.frame(list(ENTRY = 1:492, NAME = NAME, REPS = REPS))
head(treatment_list, 12) 
tail(treatment_list, 12)
prep_deseign2 <- partially_replicated(
  nrows = 30, 
  ncols = 20, 
  planter = "serpentine", 
  plotNumber = 101,
  seed = 41,
  data = treatment_list
)
prep_deseign2$infoDesign
prep_deseign2$layoutRandom
prep_deseign2$plotNumber
head(prep_deseign2$fieldBook, 10)

## End(Not run)


Plot a FielDHub object

Description

Draw a field layout plot for a FielDHub object.

Usage

## S3 method for class 'FielDHub'
plot(x, ...)

Arguments

x

a object inheriting from class FielDHub

...

further arguments passed to utility function plot_layout().

  • layout a integer. Options available depend on the type of design and its characteristics

  • l a integer to specify the location to plot.

  • planter it can be serpentine or cartesian. It has no effect on split-plot and split-split-plot designs in complete blocks (type = 2), whose whole plots are numbered in a fixed order.

  • stacked it can be vertical or horizontal stacked layout.

  • nrows, ncols the rows and columns of a field grid, as in field_layout(); they cannot be combined with layout. With them, stacked arranges the replicates in that field ("vertical", "horizontal" or "grid_panel"); when it is not given, the stacking whose replicate is the most square is drawn. A design built with nrows or ncols draws only that grid: another planter or stacked is an error.

  • field_grid FALSE removes the white line drawn around every plot in maps that have one. Other arguments are passed to desplot.

Value

Author(s)

Didier Murillo [aut]

Examples

## Not run: 
# Example 1: Plot a RCBD design with 24 treatments and 3 reps.
s <- RCBD(t = 24, reps = 3, plotNumber = 101, seed = 12)
plot(s)

## End(Not run)


Print a FielDHub object

Description

Prints the design parameters and the first rows of the field book of any FielDHub design, including results saved by earlier versions of FielDHub.

Usage

## S3 method for class 'FielDHub'
print(x, n, ...)

Arguments

x

an object inheriting from class

n

a single integer. If positive or zero, size for the resulting object: number of elements for a vector (including lists), rows for a matrix or data frame or lines for a function. If negative, all but the n last/first number of elements of x.

...

further arguments passed to head.

Value

an object inheriting from class FielDHub

Author(s)

Thiago de Paula Oliveira, thiago.paula.oliveira@alumni.usp.br [aut], Didier Murillo [aut]

Examples

# Example 1: Generates a CRD design with 5 treatments and 5 reps each.
crd1 <- CRD(t = 5, reps = 5, plotNumber = 101,
seed = 1985, locationNames = "Fargo")
crd1$infoDesign
print(crd1)


Print a fieldLayout plot object

Description

Prints a plot object of class fieldLayout.

Usage

## S3 method for class 'fieldLayout'
print(x, ...)

Arguments

x

a plot object inheriting from class fieldLayout.

...

unused, for extensibility.

Value

a plot object inheriting from class fieldLayout.

Author(s)

Didier Murillo [aut]


Print a design-aware trait simulation

Description

Summarize the simulation settings and show the first rows of the simulated field book. The full results stay in the object: field_book, responses, effects (the plot-aligned effects behind each draw), spatial_draws (the true spatial correlations) and metadata.

Usage

## S3 method for class 'fieldhub_simulation'
print(x, n = 6L, ...)

Arguments

x

A fieldhub_simulation returned by simulate.FielDHub().

n

Number of field-book rows to show.

...

Unused.

Value

x, invisibly.


Print the summary of a FielDHub object

Description

Print summary information on the design parameters, and data frame structure

Usage

## S3 method for class 'summary.FielDHub'
print(x, ...)

Arguments

x

an object inheriting from class FielDHub

...

Unused, for extensibility

Value

an object inheriting from class FielDHub

Author(s)

Thiago de Paula Oliveira, thiago.paula.oliveira@alumni.usp.br [aut], Didier Murillo [aut]


Read a validated recorded design

Description

Read a validated recorded design

Usage

read_design(file, format = "rds")

Arguments

file

Local filename. Only read serialized files from trusted sources.

format

Explicit format key from design_formats(); currently "rds" is the lossless import format.

Details

Imports validate the result schema, recorded parameters and known engine. They do not randomize, reconstruct a design, or execute an R script. Unknown schema versions are rejected, not silently coerced. Pre-metadata legacy objects remain usable through readRDS() but do not contain the recorded-input contract required by this importer.

Value

The complete saved result, unchanged. File/format input mistakes raise fieldhub_input_error; corrupt or incompatible contents raise fieldhub_import_error, with the original condition in parent.

Examples

file <- tempfile(fileext = ".rds")
x <- RCBD(t = 5, reps = 3, seed = 27)
write_design(x, file)
identical(read_design(file), x)
unlink(file)

Generates a Rectangular Lattice Design.

Description

It randomly generates a rectangular lattice design across locations.

Usage

rectangular_lattice(
  t = NULL,
  k = NULL,
  r = NULL,
  l = 1,
  plotNumber = 101,
  locationNames = NULL,
  seed = NULL,
  data = NULL,
  reps = NULL,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

t

Number of treatments, or a character vector with the treatment labels.

k

Size of incomplete blocks (number of units per incomplete block).

r

Deprecated alias for reps; positional calls remain supported.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

locationNames

(optional) Names for each location.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

data

(optional) Data frame with label list of treatments.

reps

Number of full resolvable replicates per location.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the serpentine planting path of the whole field. See field_layout for how the design is placed.

stacked

How the replicates of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of replicates). It needs nrows or ncols. By default the arrangement whose replicate is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout.

Value

A list with two elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters, using reps for replication. Under the same package versions and RNG settings, rebuild a result x with do.call(rectangular_lattice, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

Examples

# Example 1: Generates a rectangular lattice design with 6 full blocks, 4 units per IBlock (k)
# and 20 treatments in one location.
rectangularLattice1 <- rectangular_lattice(t = 20, k = 4, reps = 6, l = 1,
                                           plotNumber = 101,
                                           locationNames = "FARGO", 
                                           seed = 126)
rectangularLattice1$infoDesign
head(rectangularLattice1$fieldBook,12)

# Example 2: Generates a rectangular lattice design with 5 full blocks, 7 units per IBlock (k)
# and 56 treatments across 2 locations.
# In this case, we show how to use the option data.
treatments <- paste("ND-", 1:56, sep = "")
ENTRY <- 1:56
treatment_list <- data.frame(list(ENTRY = ENTRY, TREATMENT = treatments))
head(treatment_list) 
rectangularLattice2 <- rectangular_lattice(t = 56, k = 7, reps = 5, l = 2,
                                           plotNumber = c(1001,2001),
                                           locationNames = c("Loc1", "Loc2"), 
                                           seed = 127,
                                           data = treatment_list)
rectangularLattice2$infoDesign
head(rectangularLattice2$fieldBook,12)


Reconstruct a design from its recorded inputs

Description

Calls the design engine using the input parameters and random-number settings recorded in a result's metadata.

Usage

reproduce_design(x)

Arguments

x

A FielDHub design, allocation plan, or pair-swap optimization result with recorded parameters.

Details

The caller's RNG settings and .Random.seed are restored on exit, including when reconstruction fails. Arguments are passed as values, so language objects in the parameter list are not evaluated as code.

Reproduction requires the same software versions and platform for algorithms whose results depend on numerical optimization. A different FielDHub version signals a fieldhub_reproduction_warning; dependency or platform differences are not checked. Older results without recorded parameters cannot be reconstructed automatically, but remain usable for printing and plotting.

Value

A newly generated design or allocation plan, invisibly.

Examples

x <- RCBD(t = 5, reps = 3, seed = 38)
identical(reproduce_design(x), x)

Reconstruct recorded simulated responses

Description

Replays a design-based Gaussian, classic truncated-normal or spatial AR1-by-AR1 simulation using its saved input field book, parameters, seed, and RNG settings.

Usage

reproduce_simulation(x)

Arguments

x

A simulation record containing input_field_book, field_book, and metadata. Metadata must contain model, schema_version, seed, rng_kind, package_version, and the named parameters used by that model.

Details

This reconstructs the responses, not the experimental design or its layout: it starts from the exact saved input field book. Use reproduce_design() separately to reconstruct the experimental design. The caller's RNG settings and .Random.seed are restored on exit. R cannot save the normal value that Box-Muller holds in reserve, so when the caller uses Box-Muller normals, replaying a record made under another normal generator discards that reserved value and the caller's next rnorm() draw differs. Records made by simulate() under Box-Muller use a private stream and leave it untouched. Recorded arguments are passed as values rather than evaluated as R code. A changed FielDHub version signals a fieldhub_reproduction_warning; reproduction across software versions or platforms is not guaranteed.

Spatial min_value and max_value determine the model's center and genetic-effect scale, not hard response bounds. Spatial records retain unrounded per-location simulation values separately from the field book, whose responses are rounded to two decimal places. Classic records use a truncated-normal model, with rounding also applied to the field book.

Value

The reconstructed simulation record, invisibly.

See Also

reproduce_design()


Generates a Resolvable Row-Column Design (RowColD)

Description

It randomly generates a resolvable row-column design (RowColD). The design is optimized in both rows and columns blocking factors. The randomization can be done across multiple locations.

Usage

row_column(
  t = NULL,
  nrows = NULL,
  r = NULL,
  l = 1,
  plotNumber = 101,
  locationNames = NULL,
  seed = NULL,
  iterations = NULL,
  data = NULL,
  method = c("onestage", "twostage"),
  latinize = FALSE,
  reps = NULL
)

Arguments

t

Number of treatments, or a character vector with the treatment labels.

nrows

Number of rows of a full resolvable replicate.

r

Deprecated alias for reps; positional calls remain supported.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

locationNames

(optional) Names for each location.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

iterations

Finite positive whole-number optimization budget, at most .Machine$integer.max. Its meaning and default depend on method. For method = "onestage" it is the effort of the joint stage only: the number of joint searches is max(1, round(10 * iterations / 200)), so the default 200 runs 10 joint searches and values up to 29 run one. The first stage (the row search and the columns within the rows) and the repair of a singular joint model always run in full, whatever iterations is. On large designs the work cap of the search ends it before that many joint searches have run, so iterations is then an upper limit on their number. For method = "twostage" it is the effort of the row search: its default evaluation budget is scaled by iterations / 1000, so the default 1000 is the full search, smaller values stop it earlier (1 is the smallest effort) and larger values allow a longer search. It does not change the column design. If NULL (the default), a value appropriate to the chosen method is used.

data

(optional) Data frame with label list of treatments

method

Optimization strategy for the row and column blocking factors. Either "onestage" (default) or "twostage". With "onestage" (also known as simultaneous) FielDHub's block engine searches the rows first and then improves the joint row-by-column D-criterion without lowering the row efficiencies, which usually yields a higher joint row-by-column A-Efficiency (see Details and the Row-by-Column row of blocksModel); iterations sets the effort of its joint stage. With "twostage" the columns are optimized first, as blocks nested in replicates, by FielDHub's own block engine, and the rows are then improved by the same engine, keeping the columns fixed. "onestage" falls back to "twostage", with one warning, for very small designs whose joint model has too few residual degrees of freedom (or where no full-rank joint design was found), so "twostage" rarely has to be requested explicitly.

latinize

If TRUE, optimize the row and column blocking factors as crossed (latinized) effects shared across the replicates, so that each treatment tends to appear in different rows and columns across the replicates. By default FALSE. Only meaningful with method = "onestage"; it is ignored for method = "twostage" (which cannot latinize across replicates), where passing latinize = TRUE is ignored with a warning. If method = "onestage" falls back to "twostage" (see Details), the returned design is not latinized and the warning says so.

reps

Number of full resolvable replicates per location.

Details

With method = "twostage", the Row-Column design is built in two stages. The first step constructs the blocking factor Columns using Incomplete Block Units from an incomplete block design that sets the number of incomplete blocks as the number of Columns in the design, each of which has a dimension equal to the number of Rows. Once this design is generated, the Rows are used as the Row blocking factor, which is optimized while the Columns are kept fixed. To optimize the Rows while keeping the optimized Columns, FielDHub's block engine treats the rows of each replicate as incomplete blocks and searches over swaps of two plots of the same Column in different Rows, so every column keeps its treatments and every replicate holds each treatment once. Starting from the column design, it accepts swaps that improve the row blocks' D-criterion until no single swap improves it, then tries a few random escapes from that local optimum. The iterations argument sets the effort of this row search (see iterations). Earlier versions of FielDHub improved the rows with random greedy swaps instead, so their seeded "twostage" layouts differ.

When method = "onestage" (the default, also called simultaneous), the rows and columns are optimized together by FielDHub's block engine, in stages. First the rows are searched on their own, as incomplete blocks within each replicate, and the columns are then arranged within the rows without changing them. A joint stage then improves the joint row-by-column D-criterion of the standard analysis model (rows and columns adjusted together) with swaps of two plots of the same replicate, accepting a swap only if it does not lower the row efficiencies reached in the first stage; a first-stage design whose joint model is singular is repaired before this stage. Several joint searches are run, each from its own first-stage design; of those that end with a joint model of full rank, the one with the best row D- and A-Efficiency, and then the best joint D-Efficiency, is returned. The joint row-by-column A-Efficiency is reported as the Row-by-Column row of blocksModel. With the default latinize = FALSE the rows and columns are nested within the replicates, the criterion that "twostage" also uses, and the joint efficiency is typically higher than with "twostage"; with latinize = TRUE the rows and columns are shared across replicates (see below). The size of the joint gain is layout-dependent and tends to be largest for small designs with few replicates. For method = "onestage", iterations sets the effort of the joint stage only (see iterations).

method = "onestage" falls back to method = "twostage" with a single warning, rather than failing, so a design is still produced, when the joint row-and-column model has too few residual degrees of freedom to estimate every treatment comparison (very small designs), or no joint search found a design whose joint model has full rank. The fallback design is a nested twostage design: with latinize = TRUE the warning says that the returned design is not latinized.

No design is refused for its size. The work of the onestage search is capped instead: once the cap is spent the search stops and returns the design it holds. On large designs it is therefore the cap, not iterations, that sets the number of joint searches, and infoDesign$joint_searches reports the number asked for and the number that ran to their end. The result is still an optimized onestage design, with the rows and columns coded as requested, and it is reproducible from the seed; no warning is given for it. Only for designs beyond about 2000 treatments (fewer with more than four replicates), whose joint search cannot be started at all, does row_column() give one warning: it then returns an onestage design in which the rows, and the columns within the rows, were optimized as far as their own searches could be started, and says which.

Setting latinize = TRUE (only available with method = "onestage") codes the rows and columns as crossed blocking factors shared across the replicates, so that a treatment tends to occupy different rows and different columns in the different replicates (a latinized resolvable row-column design in the sense of John and Williams). This guards against the same treatment recurring in the same field row or column over the whole trial, not just within a replicate, and is useful when a field trend runs along the whole-field rows or columns. It optimizes a different (crossed) model than the default nested one, so the two are not directly comparable, and full latinization is only possible when there are at least as many rows and columns as replicates. By default (latinize = FALSE) the rows and columns stay nested within each replicate. latinize has no effect for method = "twostage", which cannot latinize across replicates.

Value

A list with five elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters, using reps for replication. Under the same package versions and RNG settings, rebuild a result x with do.call(row_column, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

Examples


# Example 1: Generates a row-column design with 2 full blocks and 24 treatments
# and 6 rows, for one location. This uses the default method = "onestage", for
# which a small number of iterations (one joint search) already captures most
# of the joint-efficiency gain.
rowcold1 <- row_column(
  t = 24, 
  nrows = 6, 
  reps = 2,
  l = 1, 
  plotNumber= 101, 
  locationNames = "Loc1",
  iterations = 20,
  seed = 21
)
rowcold1$infoDesign
rowcold1$resolvableBlocks
head(rowcold1$fieldBook,12)

# Example 2: Generates a row-column design with 2 full blocks and 30 treatments
# and 5 rows, for one location, using the default method = "onestage".
# In this case, we show how to use the option data.
treatments <- paste("ND-", 1:30, sep = "")
ENTRY <- 1:30
treatment_list <- data.frame(list(ENTRY = ENTRY, TREATMENT = treatments))
head(treatment_list)
rowcold2 <- row_column(
  t = 30, 
  nrows = 5, 
  reps = 2,
  l = 1, 
  plotNumber= 1001, 
  locationNames = "A",
  seed = 15,
  iterations = 20,
  data = treatment_list
)
rowcold2$infoDesign
rowcold2$resolvableBlocks
head(rowcold2$fieldBook,12)

# Example 3: Same design as Example 1 but using the historical two-stage
# optimization (method = "twostage"): columns first, then rows. For
# twostage, iterations scales the effort of the row search (default 1000,
# the full search).
rowcold3 <- row_column(
  t = 24,
  nrows = 6,
  reps = 2,
  l = 1,
  plotNumber = 101,
  locationNames = "Loc1",
  method = "twostage",
  seed = 21
)
rowcold3$infoDesign
# The Row-by-Column row reports the joint row-by-column A-Efficiency.
rowcold3$blocksModel
head(rowcold3$fieldBook, 12)



Run the Shiny Application

Description

Run the Shiny Application

Usage

run_app(..., launch.browser = TRUE, workers = 0L)

Arguments

...

Unused, for extensibility

launch.browser

Logical. If ‘TRUE', the application is launched in the system’s default web browser.

workers

Non-negative integer. Background workers; the default 0L keeps synchronous execution and does not start any worker processes.

Details

Constructing the app does not change R options. On startup, uploads are limited to 100 MiB (100 * 1024^2 bytes); when the app stops, the previous upload-limit option is restored, including an unset option. Shiny uses a process-wide upload limit, shared by the app's sessions while it is running. Closing one session does not restore the limit for others.

The standard app packages are installed with FielDHub. If any are unavailable, this function signals a fieldhub_dependency_error with an installation command and the missing package names in its packages field. It never installs packages automatically. Only the background-worker backend is optional.

With workers > 0, an installed package and the optional mirai package run design jobs in a private background pool. Other sessions remain responsive while a design runs. The pool closes when the app stops. Without mirai, or with development source, execution stays synchronous with a message.

Value

A shiny app object


Simulate a continuous trait on a FielDHub design

Description

Generate Gaussian plot responses using the treatment and experimental units of the realized randomization. Repeated entries, including checks, share a treatment effect across plots and locations. Each draw generates new random effects. Filler plots remain in the field book with missing responses.

Usage

## S3 method for class 'FielDHub'
simulate(
  object,
  nsim = 1,
  seed = NULL,
  ...,
  trait = "YIELD",
  mean = 100,
  residual_sd = 8,
  treatment_sd = NULL,
  design_sd = NULL,
  location_sd = NULL,
  spatial = FALSE
)

Arguments

object

A FielDHub field design.

nsim

Positive number of independent trials to draw.

seed

Simulation seed. With NULL, one seed is drawn and recorded. If R is using Box-Muller normals, simulation draws from a private stream to preserve the caller's cached normal.

...

Reserved for future extensions.

trait

Name of the response column for one draw. Multiple draws use this name with a numeric suffix.

mean

Trait mean, or a named vector giving the mean for each location.

residual_sd

Nonnegative plot-error standard deviation, or a named vector giving the standard deviation for each location.

treatment_sd

Nonnegative standard deviation of the treatment signal. The default is 1.25 times the typical residual SD. For factorial treatments, its variance is divided equally among the main effects and a combination-specific interaction.

design_sd

Nonnegative standard deviation for each design term, or a named vector overriding specific terms. Omitted terms use half the typical residual SD.

location_sd

Standard deviation of independent location shifts when mean is a single unnamed value and the trial has several locations. Defaults to 0.625 times the typical residual SD.

spatial

FALSE (default), TRUE for defaults, or a named list overriding sd (half the typical residual SD), rho_row and rho_col. The spatial effect is a separable AR1 x AR1 field with standard deviation sd: rho_row is the correlation between plots in adjacent rows of the same column, rho_col between plots in adjacent columns of the same row, and plots dr rows and dc columns apart have correlation rho_row^dr * rho_col^dc. Each correlation is either one fixed value or a range c(low, high), strictly between -1 and 1. A range is drawn from uniformly for every draw and every location, so each location of each simulated trial has its own field. The drawn values depend only on seed, nsim and the number of locations, so two layouts simulated with the same seed share them. A correlation that is not given is drawn from c(0.15, 0.9); so is every correlation with spatial = TRUE. The values used are returned in spatial_draws. Spatial correlation requires physical ROW and COLUMN in the field book, with unique coordinate pairs within each location. A Latin square or row-column design stores its experimental rows and columns there, so first replace its field book with the physical layout: x$fieldBook <- field_layout(x), then simulate(x, spatial = TRUE). The layout keeps the experimental axes as ROW_SQ/COLUMN_SQ or ROW_REP/COLUMN_REP, so the design effects are unchanged.

Details

The typical residual SD is the arithmetic mean of the location residual SDs. These defaults scale the trait signal and the effects of the design when the user changes the residual SD to suit a trait's units.

Value

A fieldhub_simulation list with the field book augmented by the responses, the input field book, the response data frame, one list of plot-aligned effect contributions per draw, spatial_draws (with a spatial effect: the true rho_row and rho_col of every draw and LOCATION, whether drawn or fixed; otherwise NULL), and replay metadata. Standard deviations are in trait units and the Gaussian response is unbounded.

See Also

reproduce_simulation()

Examples

x <- RCBD(t = 6, reps = 3, nrows = 3, seed = 20)
sim <- stats::simulate(x, seed = 42, mean = 6, residual_sd = 0.4,
                       treatment_sd = 0.6, design_sd = 0.3)
head(sim$field_book)

# Spatial simulation of a row-column design on its physical layout
rc <- row_column(t = 12, nrows = 3, reps = 2, seed = 1)
rc$fieldBook <- field_layout(rc)
sim_rc <- stats::simulate(rc, seed = 7, spatial = list(rho_row = 0.6, rho_col = 0.3))
sim_rc

# Correlations drawn for each trial: the true values are in spatial_draws
sim_drawn <- stats::simulate(rc, nsim = 3, seed = 7,
                             spatial = list(rho_row = c(0.3, 0.9), rho_col = c(0.1, 0.5)))
sim_drawn$spatial_draws

Unreplicated designs using the sparse allocation approach

Description

Unreplicated designs using the sparse allocation approach

Usage

sparse_allocation(
  lines,
  nrows,
  ncols,
  l,
  planter = "serpentine",
  plotNumber,
  copies_per_entry,
  checks = NULL,
  exptName = NULL,
  locationNames,
  sparse_list,
  seed,
  data = NULL,
  year = NULL,
  checksPercent = NULL,
  spread_checks = FALSE,
  dist_method = "euclidean"
)

Arguments

lines

Number of genotypes, experimental lines or treatments.

nrows

Number of rows in the field.

ncols

Number of columns in the field.

l

Number of locations or sites. By default l = 1.

planter

Option for serpentine or cartesian plot arrangement. By default planter = 'serpentine'.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

copies_per_entry

Number of copies per plant. When design is sparse then copies_per_entry < l

checks

Number of genotypes checks.

exptName

(optional) Name of the experiment.

locationNames

(optional) Names each location.

sparse_list

(optional) A class "Sparse" object generated by do_optim() function.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

data

(optional) Data frame with 2 columns: ENTRY | NAME . ENTRY must be numeric.

year

(optional) Year recorded in the YEAR column of the field book. By default the current year.

checksPercent

(optional) Percentage of checks in each location, one of the options available for the field. By default the last (largest) option.

spread_checks

Logical. Exchange check identities among the existing check plots of each location to increase separation of repeated checks, as in diagonal_arrangement(). The allocation of entries to locations, test entries, filler plots, the check plots themselves and each check's replication in a location stay fixed. The default FALSE preserves the original randomization.

dist_method

Distance between field coordinates for check optimization: "euclidean" (default) or "manhattan". Grid steps have equal scale.

Details

The allocation of entries to locations comes from do_optim(); see its Details for the search, and for allocations that changed in FielDHub 1.7.0.

Check optimization is the deterministic local exchange described in diagonal_arrangement(), run in each location on its own. It measures spacing, not statistical precision.

Value

A list with nine elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(sparse_allocation, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb]

References

Edmondson, R.N. Multi-level Block Designs for Comparative Experiments. JABES 25, 500–522 (2020). https://doi.org/10.1007/s13253-020-00416-0

Examples

sparse <- sparse_allocation(
  lines = 120,
  l = 4,
  copies_per_entry = 3,
  checks = 4,
  locationNames = c("LOC1", "LOC2", "LOC3", "LOC4"),
  seed = 1234
)

Split a population of genotypes randomly into several locations.

Description

Split a population of genotypes randomly into several locations, with the aim of having approximatelly the same number of replicates of each genotype, line or treatment per location.

Usage

split_families(l = NULL, data = NULL, seed = NULL)

Arguments

l

Number of locations.

data

Data frame with the entry (ENTRY) and the labels of each treatment (NAME) and number of individuals per family group (FAMILY).

seed

(optional) A single real number specifying the random seed. When omitted, one integer is drawn from the current random-number stream and recorded in infoDesign$seed and metadata$seed; the allocation's own randomization does not change the caller's stream.

Details

To reproduce an allocation previously made with set.seed(s); split_families(l, data), use split_families(l, data, seed = s).

Value

A list with two elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(split_families, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

Examples

# Example 1: Split a population of 3000 and 200 families into 8 locations. 
# Original dataset is been simulated.
set.seed(77)
N <- 2000; families <- 100
ENTRY <- 1:N
NAME <- paste0("SB-", 1:N)
FAMILY <- vector(mode = "numeric", length = N)
x <- 1:N
for (i in x) { FAMILY[i] <- sample(1:families, size = 1, replace = TRUE) }
gen.list <- data.frame(list(ENTRY = ENTRY, NAME = NAME, FAMILY = FAMILY))
head(gen.list)
# Now we are going to use the split_families() function.
split_population <- split_families(l = 8, data = gen.list, seed = 77)
print(split_population)
summary(split_population)
head(split_population$data_locations,12)


Generates a Split Plot Design

Description

It randomly generates a split plot design (SPD) across locations.

Usage

split_plot(
  wp = NULL,
  sp = NULL,
  reps = NULL,
  type = 2,
  l = 1,
  plotNumber = 101,
  seed = NULL,
  locationNames = NULL,
  factorLabels = TRUE,
  data = NULL,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

wp

Number of whole plots, as an integer or a vector.

sp

Number of sub plots per whole plot, as an integer or a vector.

reps

Number of blocks (full replicates).

type

Option for CRD or RCBD designs. Values are type = 1 (CRD) or type = 2 (RCBD). By default type = 2.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

locationNames

(optional) Names for each location.

factorLabels

(optional) If TRUE retain the levels labels from the original data set otherwise, numeric labels will be assigned. Default is factorLabels =TRUE.

data

(optional) Data frame with label list of treatments.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the serpentine planting path of the whole field. See field_layout for how the design is placed.

stacked

How the replicates of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of replicates). It needs nrows or ncols. By default the arrangement whose replicate is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout. An error for type = 1, which has no replicates to stack.

Value

A list with two elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(split_plot, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

References

Federer, W. T. (1955). Experimental Design. Theory and Application. New York, USA. The Macmillan Company.

Examples

# Example 1: Generates a split plot design SPD with 4 whole plots, 2 sub plots per whole plot,
# and 4 reps in an RCBD arrangement. This in for a single location.
SPDExample1 <- split_plot(wp = 4, sp = 2, reps = 5, l = 1, 
                          plotNumber = 101, 
                          seed = 14,
                          type = 2, 
                          locationNames = "FARGO")
SPDExample1$infoDesign
SPDExample1$layoutlocations
head(SPDExample1$fieldBook,12)

# Example 2: Generates a split plot design SPD with 5 whole plots 
# (4 types of fungicide + one control), 10 sub plots per whole plot (10 bean varieties), 
# and 6 reps in an RCBD arrangement. This in 3 locations or sites.
# In this case, we show how to use the option data.
wp <- c("NFung", paste("Fung", 1:4, sep = ""))  # Fungicides (5 Whole plots)
sp <- paste("Beans", 1:10, sep = "")            # Beans varieties (10 sub plots)
split_plot_Data <- data.frame(list(WHOLPLOT = c(wp, rep(NA, 5)), SUBPLOT = sp))
head(split_plot_Data, 12)
SPDExample2 <- split_plot(reps = 6, l = 3, 
                          plotNumber = c(101, 1001, 2001),
                          seed = 23, 
                          type = 2, 
                          locationNames = c("A", "B", "C"),
                          data = split_plot_Data)
SPDExample2$infoDesign
SPDExample2$layoutlocations
head(SPDExample2$fieldBook,12)
             
                  

Generates a Split Split Plot Design

Description

It randomly generates a split split plot design (SSPD) across locations.

Usage

split_split_plot(
  wp = NULL,
  sp = NULL,
  ssp = NULL,
  reps = NULL,
  type = 2,
  l = 1,
  plotNumber = 101,
  seed = NULL,
  locationNames = NULL,
  factorLabels = TRUE,
  data = NULL,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

wp

Number of whole plots, as an integer or a vector.

sp

Number of sub plots per whole plot, as an integer or a vector.

ssp

Number of sub-sub plots, as an integer or a vector.

reps

Number of blocks (full replicates).

type

Option for CRD or RCBD designs. Values are type = 1 (CRD) or type = 2 (RCBD). By default type = 2.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

locationNames

(optional) Names for each location.

factorLabels

(optional) If TRUE retain the levels labels from the original data set otherwise, numeric labels will be assigned. Default is factorLabels =TRUE.

data

(optional) Data frame with label list of treatments.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the serpentine planting path of the whole field. See field_layout for how the design is placed.

stacked

How the replicates of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of replicates). It needs nrows or ncols. By default the arrangement whose replicate is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout. An error for type = 1, which has no replicates to stack.

Value

A list with two elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(split_split_plot, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

References

Federer, W. T. (1955). Experimental Design. Theory and Application. New York, USA. The Macmillan Company.

Examples

# Example 1: Generates a split split plot design SSPD with 5 whole plots, 2 sub-plots,
# 3 sub-sub plots, and 3 reps in an RCBD arrangement. This is for one location.
SSPD1 <- split_split_plot(wp = 4, sp = 2, ssp = 3, reps = 5, l = 1, 
                          plotNumber = 101, 
                          seed = 23, 
                          type = 2, 
                          locationNames = "FARGO")
SSPD1$infoDesign
head(SSPD1$fieldBook,12)

# Example 2: Generates a split split plot design SSPD with 2 whole plost 
# (Irrigation, No irrigation), 5 sub plots (4 types of fungicide + one control), and 
# 10 sub-sub plots (Ten varieties of beans), and 4 reps in an RCBD arrangement.
# This is for 3 locations. In this case, we show how to use the option data.
wp <- paste("IRR_", c("NO", "Yes"), sep = "") #Irrigation (2 Whole plots)
sp <- c("NFung", paste("Fung", 1:4, sep = "")) #Fungicides (5 Sub plots)
ssp <- paste("Beans", 1:10, sep = "") #Beans varieties (10 Sub-sub plots)
split_split_plot_Data <- data.frame(list(WHOLPLOT = c(wp, rep(NA, 8)), 
                                         SUBPLOT = c(sp, rep(NA, 5)),
                                         SUB_SUBPLOTS = ssp))
head(split_split_plot_Data, 10)
SSPD2 <- split_split_plot(reps = 4, l = 3, 
                          plotNumber = c(101, 1001, 2001),
                          seed = 23, 
                          type = 2, 
                          locationNames = c("A", "B", "C"),
                          data = split_split_plot_Data)
SSPD2$infoDesign
head(SSPD2$fieldBook,12)
             

Generates a Square Lattice Design.

Description

It randomly generates a square lattice design across locations.

Usage

square_lattice(
  t = NULL,
  k = NULL,
  r = NULL,
  l = 1,
  plotNumber = 101,
  locationNames = NULL,
  seed = NULL,
  data = NULL,
  reps = NULL,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

t

Number of treatments, or a character vector with the treatment labels.

k

Size of incomplete blocks (number of units per incomplete block).

r

Deprecated alias for reps; positional calls remain supported.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

locationNames

(optional) Names for each location.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

data

(optional) Data frame with label list of treatments.

reps

Number of full resolvable replicates per location.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the serpentine planting path of the whole field. See field_layout for how the design is placed.

stacked

How the replicates of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of replicates). It needs nrows or ncols. By default the arrangement whose replicate is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout.

Value

A list with two elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters, using reps for replication. Under the same package versions and RNG settings, rebuild a result x with do.call(square_lattice, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

Examples

# Example 1: Generates a square lattice design with 5 full blocks, 8 units per IBlock,
# 8 IBlocks for a square number of treatmens of 64 in two locations.
squareLattice1 <- square_lattice(t = 64, k = 8, reps = 5, l = 2,
                                 plotNumber = c(1001, 2001),
                                 locationNames = c("FARGO", "MINOT"), 
                                 seed = 1986)
squareLattice1$infoDesign
head(squareLattice1$fieldBook,12)

# Example 2: Generates a square lattice design with 3 full blocks, 7 units per IBlock,
# 7 IBlocks for a square number of treatmens of 49 in one location.
# In this case, we show how to use the option data.
treatments <- paste("G", 1:49, sep = "")
ENTRY <- 1:49
treatment_list <- data.frame(list(ENTRY = ENTRY, TREATMENT = treatments))
head(treatment_list) 
squareLattice2 <- square_lattice(t = 49, k = 7, reps = 3, l = 1,
                                 plotNumber = 1001,
                                 locationNames = "CASSELTON", 
                                 seed = 1986,
                                 data = treatment_list)
squareLattice2$infoDesign
head(squareLattice2$fieldBook,12)


Strip Plot Design

Description

It randomly generates a strip plot design across locations.

Usage

strip_plot(
  Hplots = NULL,
  Vplots = NULL,
  b = 1,
  l = 1,
  plotNumber = NULL,
  planter = "serpentine",
  locationNames = NULL,
  seed = NULL,
  factorLabels = TRUE,
  randomizeH = TRUE,
  randomizeV = FALSE,
  data = NULL,
  reps = 1,
  nrows = NULL,
  ncols = NULL,
  stacked = NULL
)

Arguments

Hplots

Number of horizontal factors, as an integer or a vector.

Vplots

Number of vertical factors, as an integer or a vector.

b

Deprecated alias for reps; positional calls remain supported.

l

Number of locations. By default l = 1.

plotNumber

Numeric vector with the starting plot number for each location. By default plotNumber = 101.

planter

Option for serpentine or cartesian arrangement. By default planter = 'serpentine'.

locationNames

(optional) Names for each location.

seed

(optional) Real number that specifies the starting seed to obtain reproducible designs.

factorLabels

(optional) If TRUE retain the levels labels from the original data set otherwise, numeric labels will be assigned. Default is factorLabels =TRUE.

randomizeH

Logical flag: TRUE to randomize horizontal strips separately in each replicate; FALSE to randomize once per location and reuse.

randomizeV

Logical flag: TRUE to randomize vertical strips separately in each replicate; FALSE to randomize once per location and reuse.

data

(optional) data frame with the labels of vertical and horizontal plots.

reps

Number of blocks (full replicates) per location. Default is one.

nrows, ncols

Optional positive whole numbers: the rows and columns of the field at each location. If only one is given, the other follows from the number of plots. The field book then has ROW and COLUMN, and its plots are numbered along the planting path of the whole field (see planter). See field_layout for how the design is placed.

stacked

How the replicates of a field of given dimensions are arranged: "vertical" (one above another, each across all the columns of the field), "horizontal" (side by side, each down all its rows) or "grid_panel" (in rows and columns of replicates). It needs nrows or ncols. By default the arrangement whose replicate is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. See field_layout.

Value

A list with four elements.

Reproducibility

The result records effective inputs and the resolved seed in metadata$parameters. Under the same package versions and RNG settings, rebuild a result x with do.call(strip_plot, x$metadata$parameters).

Author(s)

Didier Murillo [aut], Salvador Gezan [aut], Ana Heilman [ctb], Thomas Walk [ctb], Johan Aparicio [ctb], Richard Horsley [ctb]

References

Federer, W. T. (1955). Experimental Design. Theory and Application. New York, USA. The Macmillan Company.

Examples

# Example 1: Generates a strip plot design with 5 vertical strips and 4 horizontal strips,
# with 3 reps in one location.
H <- paste("H", 1:4, sep = "")
V <- paste("V", 1:5, sep = "")
strip1 <- strip_plot(
  Hplots = H,
  Vplots = V,
  reps = 3,
  l = 1,
  plotNumber = 101,
  planter = "serpentine",
  locationNames = "A",
  seed = 333
)
strip1$infoDesign
strip1$stripsBlockLoc
strip1$plotLayouts
head(strip1$fieldBook, 12)

# Example 2: Generates a strip plot design with 5 vertical strips and 5 horizontal strips,
# with 6 reps across to 3 locations. In this case, we show how to use the option data.
Hplots <- LETTERS[1:5]
Vplots <- LETTERS[1:4]
strip_data <- data.frame(list(HPLOTS = Hplots, VPLOTS = c(Vplots, NA)))
head(strip_data)
strip2 <- strip_plot(
  Hplots = 5,
  Vplots = 5,
  reps = 6,
  l = 3,
  plotNumber = c(101, 1001, 2001),
  planter = "cartesian",
  locationNames = c("A", "B", "C"),
  seed = 222,
  data = strip_data
)
strip2$infoDesign
strip2$stripsBlockLoc
strip2$plotLayouts
head(strip2$fieldBook, 12)


Summary a FielDHub object

Description

Summarise information on the design parameters, and data frame structure

Usage

## S3 method for class 'FielDHub'
summary(object, ...)

Arguments

object

an object inheriting from class FielDHub

...

Unused, for extensibility

Value

an object inheriting from class summary.FielDHub

Author(s)

Thiago de Paula Oliveira, thiago.paula.oliveira@alumni.usp.br

Examples

# Example 1: Generates a CRD design with 5 treatments and 5 reps each.
crd1 <- CRD(t = 5, reps = 5, plotNumber = 101,
seed = 1985, locationNames = "Fargo")
crd1$infoDesign
summary(crd1)


Swap pairs in a matrix of integers

Description

Attempts to separate repeated entries by swapping cells of different entries. Distance thresholds increase from starting_dist in steps of one. Candidate sampling, mean pairwise distance, and a centrality penalty guide the search. The last successful threshold layout is returned (with the row/column rule on, the successful layout with the fewest pairs of copies sharing a row or column; see rowcol_penalty); if none succeeds, the original matrix is returned. A requested minimum distance is not guaranteed.

Usage

swap_pairs(
  X,
  starting_dist = 3,
  stop_iter = 10,
  lambda = 0.5,
  dist_method = "euclidean",
  candidate_sample_size = 4,
  seed = NULL,
  rowcol_penalty = 0,
  rowcol_scope = "pairs"
)

Arguments

X

A numeric matrix of whole-number entry identifiers within R's integer range. Missing cells are inactive positions and never move.

starting_dist

First distance threshold; a finite nonnegative number. Default is 3.

stop_iter

Maximum complete swap sweeps per threshold, as a nonnegative whole number within R's integer range. Default is 10.

lambda

Finite nonnegative weight for the centrality penalty. Default is 0.5.

dist_method

Coordinate distance used for candidate filtering, scoring, stopping, and reported distances: "euclidean" (default) or "manhattan".

candidate_sample_size

Maximum candidates evaluated per swap, as a positive whole number within R's integer range. Default is 4.

seed

Optional randomization seed. When omitted, one integer is drawn from the current random-number stream and recorded; the swap's own randomization does not change the caller's stream.

rowcol_penalty

Weight of the row/column rule: one number at least 0, or Inf. The default 0 turns the rule off and leaves every layout unchanged. When positive, the copies of a covered entry that share a row or a column are treated as a problem to fix even when they are far apart, and a candidate swap scores its distance score minus rowcol_penalty times the change in the number of shared pairs. Inf is strict: a swap that leaves fewer shared pairs always wins, and distance decides among equals (rows and columns first). With the rule on, the result keeps the successful threshold step with the fewest shared pairs (the largest threshold breaks ties), the search steps after it are dropped from designs, distances and rows_incidence, and diagnostics adds rowcol_penalty, rowcol_scope, retained_threshold, shared_pairs_input, shared_pairs_final and entries_sharing_final.

rowcol_scope

Entries the row/column rule covers: "pairs" (default), the entries with exactly two copies, or "all", every entry with two or more copies, checks included.

Details

The finite threshold range is bounded by the field geometry. For Euclidean distance without missing cells, the historical bound is sqrt(nrow(X)^2 + ncol(X)^2); with missing cells it is the maximum distance between active positions. For Manhattan distance it is the maximum Manhattan distance between active positions. There are at most floor(bound - starting_dist) + 1 thresholds when the bound is at least starting_dist, and none otherwise. Each threshold permits at most stop_iter complete sweeps. Diagnostics distinguish an exhausted threshold budget from completing or skipping the distance range.

Standalone calls use the shared seed contract. To reproduce a previous set.seed(s); swap_pairs(X) call, with X already constructed, pass seed = s. Calls without a seed now select an automatic seed, so their layouts can differ from previous versions. Optimization performed inside field-design engines retains its existing draw sequence. Use reproduce_design() to replay a recorded optimization result.

Value

A list containing:

optim_design

The modified matrix.

designs

A list of the retained threshold layouts, starting from the input matrix; with the row/column rule on, it ends at the kept layout.

distances

A list of the pair distances of each layout in designs.

min_distance

The minimum distance between pairs of occurrences of the same integer in the final design.

pairwise_distance

A data frame with the pairwise distances for the final design.

rows_incidence

Row-repetition counts for retained threshold steps, or for the original matrix when no step succeeds.

diagnostics

The distance metric, stop reason, total completed sweeps (iterations), per-threshold budget, number of attempted thresholds, last threshold, last attempted minimum distance, and retained minimum distance. Stop reasons are iteration_limit, distance_range_complete, and no_distance_thresholds. A failed attempt is not retained in optim_design.

metadata

The design identifier, schema and package versions, RNG settings, resolved seed and complete input parameters, including X. The result inherits from fieldhub_optimization.

References

Williams, E., Piepho, H.-P., & Whitaker, D. (2011). Augmented p-rep designs. Biometrical Journal, 53(1), 19-27. https://doi.org/10.1002/bimj.201000102

Cullis, B. R., Smith, A. B., & Coombes, N. E. (2006). On the design of early generation variety trials with correlated data. Journal of Agricultural, Biological, and Environmental Statistics, 11, 381-393. https://doi.org/10.1198/108571106X154443

Examples

set.seed(123)
X <- matrix(sample(c(rep(1:10, 2), 11:50), replace = FALSE), ncol = 10)
B <- swap_pairs(
  X,
  starting_dist = 3,
  stop_iter = 50,
  lambda = 0.5,
  dist_method = "euclidean",
  candidate_sample_size = 3,
  seed = 123
)
B$optim_design


Write a recorded design or standalone replay script

Description

Write a recorded design or standalone replay script

Usage

write_design(x, file, format = "rds", overwrite = FALSE)

Arguments

x

A validated design, allocation or optimization result with recorded parameters. App-selected layouts and simulations are separate artifacts.

file

Local output filename; its parent directory must already exist.

format

Explicit exporter key from design_formats(): "rds" saves the exact result and metadata; "r" saves a standalone script assigning the reconstructed result to design.

overwrite

One logical value. Existing files are protected by default.

Details

Serialization completes in a temporary file before the destination is copied. This protects an existing file from serialization failures, but is not an atomic filesystem transaction. Disk/copy failures still require normal backups. The temporary file is removed on exit.

R scripts embed only portable data and never evaluate recorded arguments during export. Large uploads or nonportable values require the RDS format. Reconstruction can depend on matching software versions and platform; the RDS format preserves the actual saved result independently of replay.

Value

file, invisibly. Unsupported formats and overwrite mistakes raise fieldhub_input_error; write failures raise fieldhub_export_error.

Examples

file <- tempfile(fileext = ".rds")
write_design(CRD(t = 4, reps = 2, seed = 27), file)
read_design(file)$metadata
unlink(file)