# R/clusterDistanceByApproach.details.R In LearnClust: Learning Hierarchical Clustering Algorithms

#### Documented in clusterDistanceByApproach.details

```#' @title To explain how to calculate the distance by approach option.
#' @description To explain how to calculate the distance depending on \code{option} given.
#' @param distances is a numeric vector.
#' @param approach is a string. Type of function to apply.
#' @details This function is part of the hierarchical clusterization method. The function explains how to calculate the
#' distance value from \code{distances}.
#' @details \code{approach} indicates the algorithm used to get the value. Possible values: {\code{'MAX'},
#' \code{'MIN'}, \code{'AVG'}}.
#' @author Roberto Alcántara \email{roberto.alcantara@@edu.uah.es}
#' @author Universidad de Alcalá de Henares
#' @return max, min or average from a vector.
#' @examples
#'
#' distances1 <- c(4,14,24,34)
#'
#' distances2 <- c(1:10)
#'
#' clusterDistanceByApproach(distances1,'MAX')
#'
#' clusterDistanceByApproach(distances2,'MIN')
#'
#' @export

clusterDistanceByApproach.details <-
function(distances,approach){
message("\n 'clusterDistanceByApproach' method calculates the ", approach, " of the distance vector given. \n")
message("\n It returns the ", approach, " of ", distances, "\n\n")
switch(approach,
MAX = max(distances),
MIN = min(distances),
AVG = mean(distances))
}
```

## Try the LearnClust package in your browser

Any scripts or data that you put into this service are public.

LearnClust documentation built on Nov. 30, 2020, 1:09 a.m.