First of all, I am new to R (I started yesterday).
I have two groups of points, data and centers, the first one of size n and
data
centers
n
My solution:
# data is a matrix where each row is a point # point is a vector of values euc.dist <- function(data, point) { apply(data, 1, function (row) sqrt(sum((point - row) ^ 2))) }
You can try it, like:
x <- matrix(rnorm(25), ncol=5) euc.dist(x, x[1,])