as_director | R Documentation |
Directors are functions that tell the partition algorithm what
to try to reduce. as_director()
is a helper function to create new
directors to be used in partitioner
s. partitioner
s can be created with
as_partitioner()
.
as_director(.pairs, .target, ...)
.pairs |
a function that returns a matrix of targets (e.g. a distance matrix of variables) |
.target |
a function that returns a vector of targets (e.g. the minimum pair) |
... |
Extra arguments passed to |
a function to use in as_partitioner()
Other directors:
direct_distance()
,
direct_k_cluster()
# use euclidean distance to calculate distances
euc_dist <- function(.data) as.matrix(dist(t(.data)))
# find the pair with the minimum distance
min_dist <- function(.x) {
indices <- arrayInd(which.min(.x), dim(as.matrix(.x)))
# get variable names with minimum distance
c(
colnames(.x)[indices[1]],
colnames(.x)[indices[2]]
)
}
as_director(euc_dist, min_dist)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.