I’ve created this little code and have troubles to sum up the results of the loop. Somebody can help me with it?
a = array(c(1,1,1,1,1,1,1,2,1,1,1,1,1), dim=c(4,3))
b = array(c(0,0,0,0,0,1), dim=c(2,3))
dist <- array()
for (j in 1:2) {
for (i in 1:4) {
dist <- sqrt (sum ((a[i, ]-b[j, ])^2))
print(dist)
}
}
I get 8 numbers as result, but can only display the last of it
You need to fill in your
distmatrix as you go.