Self-made Distance Matrix in R -


i want create distance matrix based on 2 columns represent point ids , column representing "distance". distances normalized maximum slope values, want distance matrix on maximum slope between 2 points. have 1 row every connection looks somehow this:

origin = c(10001,10001,10002,10002,20001,20001) destin = c(10002,20001,10001,20001,10001,10002)  

and third vector maximum slope values:

maxslope = c(0.47, 0.12, 0.47, 0.32,0.12,0.32) 

now have table looks this:

nan   10001 10002 20001 10001 nan   0.47  0.12 10002 0.47  nan   0.32 20001 0.12  0.32  nan 

i don't care values in place of "nan".

i'm pretty new r. have solution doing this? regards, simoet

you can use xtabs:

xtabs(maxslope~origin+destin)        destin origin  10001 10002 20001   10001  0.00  0.47  0.12   10002  0.47  0.00  0.32   20001  0.12  0.32  0.00 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -