Generates a Square Lattice Design.¶
Source: R/fct_square_lattice.R
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
ROWandCOLUMN, and its plots are numbered along the serpentine planting path of the whole field. Seefield_layoutfor 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 needsnrowsorncols. By default the arrangement whose replicate is the most square among those that fit the dimensions; the stacking chosen is recorded in the design. Seefield_layout.
Value¶
A list with two elements.
-
infoDesignis a list with information on the design parameters. -
fieldBookis a data frame with the square lattice design field book.
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¶
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
#> $Reps
#> [1] 5
#>
#> $IBlocks
#> [1] 8
#>
#> $NumberTreatments
#> [1] 64
#>
#> $NumberLocations
#> [1] 2
#>
#> $Locations
#> [1] "FARGO" "MINOT"
#>
#> $seed
#> [1] 1986
#>
#> $lambda
#> [1] 0.5555556
#>
#> $id_design
#> [1] 10
#>
head(squareLattice1$fieldBook,12)
#> ID LOCATION PLOT REP IBLOCK UNIT ENTRY TREATMENT
#> 1 1 FARGO 1001 1 1 1 64 G-64
#> 2 2 FARGO 1002 1 1 2 61 G-61
#> 3 3 FARGO 1003 1 1 3 2 G-2
#> 4 4 FARGO 1004 1 1 4 8 G-8
#> 5 5 FARGO 1005 1 1 5 33 G-33
#> 6 6 FARGO 1006 1 1 6 59 G-59
#> 7 7 FARGO 1007 1 1 7 39 G-39
#> 8 8 FARGO 1008 1 1 8 5 G-5
#> 9 9 FARGO 1009 1 2 1 35 G-35
#> 10 10 FARGO 1010 1 2 2 51 G-51
#> 11 11 FARGO 1011 1 2 3 10 G-10
#> 12 12 FARGO 1012 1 2 4 25 G-25
# 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)
#> ENTRY TREATMENT
#> 1 1 G1
#> 2 2 G2
#> 3 3 G3
#> 4 4 G4
#> 5 5 G5
#> 6 6 G6
squareLattice2 <- square_lattice(t = 49, k = 7, reps = 3, l = 1,
plotNumber = 1001,
locationNames = "CASSELTON",
seed = 1986,
data = treatment_list)
squareLattice2$infoDesign
#> $Reps
#> [1] 3
#>
#> $IBlocks
#> [1] 7
#>
#> $NumberTreatments
#> [1] 49
#>
#> $NumberLocations
#> [1] 1
#>
#> $Locations
#> [1] "CASSELTON"
#>
#> $seed
#> [1] 1986
#>
#> $lambda
#> [1] 0.375
#>
#> $id_design
#> [1] 10
#>
head(squareLattice2$fieldBook,12)
#> ID LOCATION PLOT REP IBLOCK UNIT ENTRY TREATMENT
#> 1 1 CASSELTON 1001 1 1 1 14 G14
#> 2 2 CASSELTON 1002 1 1 2 16 G16
#> 3 3 CASSELTON 1003 1 1 3 15 G15
#> 4 4 CASSELTON 1004 1 1 4 32 G32
#> 5 5 CASSELTON 1005 1 1 5 45 G45
#> 6 6 CASSELTON 1006 1 1 6 30 G30
#> 7 7 CASSELTON 1007 1 1 7 27 G27
#> 8 8 CASSELTON 1008 1 2 1 43 G43
#> 9 9 CASSELTON 1009 1 2 2 22 G22
#> 10 10 CASSELTON 1010 1 2 3 38 G38
#> 11 11 CASSELTON 1011 1 2 4 2 G2
#> 12 12 CASSELTON 1012 1 2 5 1 G1