[R] How to transform the paths of MST {ape} in SpatialLines objects {sp} ?

Cleber N.Borges klebyn at yahoo.com.br
Sun Oct 14 19:29:13 CEST 2012


Hello all,

I would like to transform the paths of MST {ape}  in SpatialLines objects.
But I don't understand the mechanical procedure in SpatialLines-class of 
'sp' package.

Please, somebody can help me?

Thanks in advanced.
Cleber N.Borges


### my (half) trial
library(sp);
library(ape) # for 'mst' function

n <- 20
x <- runif( n )
y <- runif( n )
coords <- cbind( x, y )
plot( coords )

r <- which( mst(dist(coords))==1, arr.ind=T )

segments( coords[r[,1],1], coords[r[,1],2], coords[r[,2],1], 
coords[r[,2],2] )



More information about the R-help mailing list