[R] matrix to coordinates

juli g. pausas juli at ceam.es
Thu Apr 24 18:26:55 CEST 2003

Dear R-users,
I'm sure it must be a specific function or a better way to convert 
matrix to x,y,z coordinates (and viceversa), than my function below (it 
works). Any help?

m2coord <- function(m)
k <- nrow(m)*ncol(m)
aa <- data.frame(r=1:k, c=1:k, v=1:k)
k <- 0
  for (i in 1:nrow(m))
  for (j in 1:ncol(m))
  k <- k+1
  aa$f[k]=i; aa$c[k]=j; aa$v[k]=m[i,j]


Juli G. Pausas
Centro de Estudios Ambientales del Mediterraneo (CEAM)
C/ C.R. Darwin 14, Parc Tecnologic,
46980 Paterna, Valencia, SPAIN
Tel: (+ 34) 96 131 8227; Fax: (+ 34) 96 131 8190
mailto:juli at ceam.es 

GCTE Fire Network - http://www.gva.es/ceam/FireNetwork

"Wars do not solve problems, wars generate even more problems"

More information about the R-help mailing list