Hello R-help, I am a recent convert to R from SAS and I am having some difficulty with output of a for loop into a matrix. I have searched the help manuals and the archives, but I can't get my code to work. It is probably a syntax error that I am not spotting. I am trying to make a distance matrix by extracting the distances from each point to all others in a vector (the for loop). I can get them all to print and can save each individually to a file, but I cannot get them to be bound into a matrix.
Here is the code that I have tried: m<-length(Day.1.flower.coords$x) #31 grid points output.matix<-matrix(0.0,m,m) for(i in 1:m){ dist<-spDistsN1(Day.1.coords.matrix, Day.1.coords.matrix[i,]) dist<-as.vector(dist) output.matrix[i,]<-dist print(dist)} The error message that I get is: Error in output.matrix[i,] <- dist : incorrect number of subscripts on matrix Thanks for your help. Ryan ~~~~~~~~~~~~~~~~~~ Ryan D. Briscoe Runquist Population Biology Graduate Group University of California, Davis [EMAIL PROTECTED] ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.