I think this is what you need
expand.grid(FactorA = c("00", "10"), FactorB = c("00", "10"))
Question
I am trying to write the data layout of a s^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.
Solution
I think this is what you need
expand.grid(FactorA = c("00", "10"), FactorB = c("00", "10"))