Hi Sarah,
thanks a lot. In this line:
result.m[cbind(factor(result$f_cell), factor(result$f_cell_neigh))] <-
result$distance
I had a problem with cbind(factor .. : the assignement to the [i,j] element
of the matrix did not work.
I solved in this manner:
- I modified censDist, so for every coupl
*PLEASE IGNORE THE PREVIOUS EMAIL, IT WAS SENT BY MISTAKE*
Hello Sarah
thanks a lot for your advice.
I followed your suggestions unitil the creation of "result"
The allocation of the values of result$distance to the matrix result.m,
however ,does not seem to work: it produces a matrix with ident
Sorry, you're right.
The result line should be:
result.m[cbind(factor(result$fcell), factor(result$cellneigh))] <-
result$distance
idcell <- data.frame(
id = seq_len(5),
fcell = sample(1:100, 5))
censDist <- expand.grid(fcell=seq_len(100), cellneigh=seq_len(100))
censDist$distance <- runi
Hello Sarah
thanks a lot for your advice.
I followed your suggestions unitl the creation of "result"
The allocation of the values of result$distance to the matrix result.m,
however ,does not seem to work: it produces a matrix with identical columns
corresponding to the last values of result$dista
I don't see any reason why a loop is out of the question, and
answering would have been much easier if you'd included the requested
reproducible data, but what about this?
This solution is robust to pairs from idcell being absent in censDist,
and to the difference from A to B being different than
Hello,
I have a sample of 1327 locations, each one idetified by an id and a
numerical code.
I need to build a spatial matrix, say, M, i.e. a 1327x1327 matrix
collecting distances among the locations.
M(i,i) should be 0, M(i,j) should contain the distance among location i and
j
I shoud use data
6 matches
Mail list logo