Is this what you want?

make.odd.matrix<-function(matsize) {
  newmat<-matrix(0,nrow=matsize,ncol=matsize)
  for(i in 1:matsize) {
   for(j in 1:matsize)
    newmat[i,j]<-ifelse(i==j,NA,abs(i-j)+1)
  }
  return(newmat)
}

Jim

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to