I am trying to write the data layout of as^k factorial design in R. So i started with the smallest factorial design,that is, 2^2 design.
The data layout of a 2^2 factorial design is :
00 10
01 11
0 indicates low level while 1 indicates high level of a factor .
that is, if i have two factors such as factor A and factor B then 10 indicates high level of factor A and low level of factor B.
So, i tried to construct the data layout in R by the following commands :
mat=matrix(0,nrow=2,ncol=2)
for(i in 0:1){
for(j in 0:1){
mat[i,j] = c(i,j)
# print(mat)
}
}
I am realizing that the problem is within mat[i, j] = c(i, j)
, particularly in c(i,j)
.
i am not understanding how to handle it so that i would get the index of mat
matrix as the element in that position of the matrix.
我觉得这就是你所需要的
expand.grid(FactorA = c("00", "10"), FactorB = c("00", "10"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.