make.phantoms | R Documentation |
The make.phantoms function will take an N
xN
matrix and add
NP
phantom elements, thus creating a matrix with N+NP
xN+NP
dimensions.
make.phantoms(x, nphantoms, name = "phantom", maxval = Inf, ...)
x |
A matrix or data.frame object, with |
nphantoms |
An integer, providing the number of phantom elements to add. |
name |
A character string, indicating the name attribute for new elements. Defaults to "phantom". |
maxval |
An integer value, the default value to give the pairs of phantoms (indeces [N+1:N+NP, N+1:N+NP]), assumed to be a maximum distance. Defaults to Inf. |
... |
Additional arguments, not used at this time. |
This function is internal to the gendistance
function, but may be
useful in manufacturing personalized distance matrices. Phantoms are fake
elements that perfectly match all elements. They can be used to discard a
certain number of elements.
a matrix or data.frame object
Cole Beck
gendistance
distancematrix
# 5x5 distance matrix
dist.mat <- matrix(c(0,5,10,15,20,5,0,15,25,35,10,15,0,25,40,15,25,25,0,15,20,35,40,15,0), nrow=5)
# add one phantom element
dm.ph <- make.phantoms(dist.mat, 1)
# create distancematrix object
distancematrix(dm.ph)
# add three phantoms
make.phantoms(dist.mat, 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.