#Cargado función "latin" a R
source("C:/Users/Administrator/Desktop/latin.R")
# verificando contenido de "latin"
latin
function (n, nrand = 20)
{
x = matrix(LETTERS[1:n], n, n)
x = t(x)
for (i in 2:n) x[i, ] = x[i, c(i:n, 1:(i - 1))]
if (nrand > 0) {
for (i in 1:nrand) {
x = x[sample(n), ]
x = x[, sample(n)]
}
}
x
}
# aleatorización de 4 tratamientos
latin(4)
[,1] [,2] [,3] [,4]
[1,] "C" "B" "D" "A"
[2,] "B" "A" "C" "D"
[3,] "D" "C" "A" "B"
[4,] "A" "D" "B" "C"
# aleatorización de 8 tratamientos
latin(8)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] "H" "C" "B" "E" "A" "F" "G" "D"
[2,] "C" "F" "E" "H" "D" "A" "B" "G"
[3,] "D" "G" "F" "A" "E" "B" "C" "H"
[4,] "E" "H" "G" "B" "F" "C" "D" "A"
[5,] "A" "D" "C" "F" "B" "G" "H" "E"
[6,] "F" "A" "H" "C" "G" "D" "E" "B"
[7,] "G" "B" "A" "D" "H" "E" "F" "C"
[8,] "B" "E" "D" "G" "C" "H" "A" "F"
Fuente de función:
Larget, B. 2007. Latin
Square Designs. Department of Botany and of Statistics; University of Wisconsin—Madison.
PowerPoint presentation Slide 6. Enlace http://www.stat.wisc.edu/courses/st572-larget/Spring2007/handouts17-4.pdf
No hay comentarios.:
Publicar un comentario