Get list of random latin squares.

latinList(nSquares = 3, nDims = 4)

Arguments

nSquares

Number of latin squares to create.

nDims

Size of latin squares.

Value

A list of latin squares, nSquares in length. Each square is nDims x nDims in size.

Details

Get list of random latin squares. At present, these are not guaranteed to be unique.

See also

Author

David Braze davebraze@gmail.com

Examples

d <- 5 ll <- latinList(3,d) ll
#> [[1]] #> [,1] [,2] [,3] [,4] [,5] #> [1,] 3 2 1 4 5 #> [2,] 5 1 2 3 4 #> [3,] 4 5 3 1 2 #> [4,] 1 4 5 2 3 #> [5,] 2 3 4 5 1 #> #> [[2]] #> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 2 5 3 4 #> [2,] 3 1 2 4 5 #> [3,] 4 5 1 2 3 #> [4,] 5 4 3 1 2 #> [5,] 2 3 4 5 1 #> #> [[3]] #> [,1] [,2] [,3] [,4] [,5] #> [1,] 3 4 2 1 5 #> [2,] 1 2 3 5 4 #> [3,] 2 5 1 4 3 #> [4,] 4 1 5 3 2 #> [5,] 5 3 4 2 1 #>
ll.mat <- Reduce(rbind,ll) cond <- letters[1:d] matrix(cond[ll.mat], ncol=d)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] "c" "b" "a" "d" "e" #> [2,] "e" "a" "b" "c" "d" #> [3,] "d" "e" "c" "a" "b" #> [4,] "a" "d" "e" "b" "c" #> [5,] "b" "c" "d" "e" "a" #> [6,] "a" "b" "e" "c" "d" #> [7,] "c" "a" "b" "d" "e" #> [8,] "d" "e" "a" "b" "c" #> [9,] "e" "d" "c" "a" "b" #> [10,] "b" "c" "d" "e" "a" #> [11,] "c" "d" "b" "a" "e" #> [12,] "a" "b" "c" "e" "d" #> [13,] "b" "e" "a" "d" "c" #> [14,] "d" "a" "e" "c" "b" #> [15,] "e" "c" "d" "b" "a"