I am writing R code to create a square matrix. So my approach is:
rows<-3 cols<-3 x<-rep(NA, rows*cols) x1 <- matrix(x,nrow=rows,ncol=cols)