x <- runif(10)
a <- pdist(x)
# a is a 10x10 matrix of distances
y <- runif(20)
a <- pdist(x,y)
# a is now a 10x20 matrix of distances (it infered that d=1)
z <- runif(10)
b <- pdist(x,z)
# b is a 1x1 matrix (it guessed that d=10)
b <- pdist(x,z,d=1)
# now b is a 10x10 matrix
z <- matrix(runif(20),ncol=10)
b <- pdist(x,z)
# now b is 1x2
Run the code above in your browser using DataLab