1 | e2dist(x, y)
|
x |
|
y |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
x<-seq(1,100, by=10) ###create a grid called "x"
y<-seq(1,200, by=10)
x.y<-rep(y, length(x))
x.x<-rep(x[1], length(y))
for (i in 2:length(x))
{
x.x<-c(x.x,rep(x[i],length(y)))
}
x<-cbind(x.x,x.y) ### x is a
y<-cbind(sample(x[,1],50), sample(x[,1],50)) ##y is a random set of points drawn from x
## The function is currently defined as
function (x, y)
{
i <- sort(rep(1:nrow(y), nrow(x)))
dvec <- sqrt((x[, 1] - y[i, 1])^2 + (x[, 2] - y[i, 2])^2)
matrix(dvec, nrow = nrow(x), ncol = nrow(y), byrow = F)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.