Hi All,
I am pretty new to R and just started learning it. Need one help regarding the below problem.
Create the following matrix elegantly:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 0 1 0 1 0 1 0 1 0 1
[2,] 1 0 1 0 1 0 1 0 1 0
[3,] 0 1 0 1 0 1 0 1 0 1
[4,] 1 0 1 0 1 0 1 0 1 0
[5,] 0 1 0 1 0 1 0 1 0 1
[6,] 1 0 1 0 1 0 1 0 1 0
[7,] 0 1 0 1 0 1 0 1 0 1
[8,] 1 0 1 0 1 0 1 0 1 0
[9,] 0 1 0 1 0 1 0 1 0 1
[10,] 1 0 1 0 1 0 1 0 1 0
I can only come up with below option
e = matrix (c(0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0), nrow=10, ncol=10, byrow=FALSE)
Looking for help if there is any other efficient way of doing that.
Thank you.