R/StrHclust.R

Defines functions StrHclust

Documented in StrHclust

#' @export
StrHclust <- function(strings.vec, nclust = 2){

   # Levenstein distance matrix
   d <- utils::adist(strings.vec)

   # hclust
   c <- stats::hclust(stats::as.dist(d))
   graphics::plot(c)
   cluster <- stats::cutree(c, nclust)

   # export df
   strClust.df <- as.data.frame(cbind(cluster, strings.vec))
   colnames(strClust.df) <- c("Cluster", "Strings")
   return(strClust.df)
}

Try the GrpString package in your browser

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

GrpString documentation built on May 2, 2019, 12:38 p.m.