R/make.dist.R

Defines functions make.dist

#' @importFrom stats dist


make.dist <- function(TS, method) {
  if (method == "sq-euclidean") {
    dist_mat <- dist(TS,
      method = "euclidean",
      diag = TRUE, upper = TRUE
    )^2
  } else if (method == "manhattan") {
    dist_mat <- dist(TS,
      method = "manhattan",
      diag = TRUE, upper = TRUE
    )
  } else if (method == "sq-chord") {
    dist_mat <- dist(sqrt(TS),
      method = "euclidean",
      diag = TRUE, upper = TRUE
    )^2
  } else {
    stop("unrecognised distance measure")
  }
  as.matrix(dist_mat)
}

Try the palaeoSig package in your browser

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

palaeoSig documentation built on March 31, 2023, 9:34 p.m.