% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/clusterX.R
\name{clusterX}
\alias{clusterX}
\title{Perform Hierarchical Clustering on Data Objects}
\usage{
clusterX(
  x,
  n_clusters = NULL,
  validity_indices = TRUE,
  plot_result = TRUE,
  input = NULL
)
}
\arguments{
\item{x}{Data frame or matrix containing numeric data to be clustered (non-numeric columns are automatically ignored). Argument is required.}

\item{n_clusters}{Integer.
If provided, specifies the number of clusters to cut the dendrogram into.
If NULL (default), the optimal number of clusters is determined automatically
using the KGS penalty function.}

\item{validity_indices}{Logical. Indicates whether to compute and print popular clustering validity indices (Silhouette, Dunn, Calinski-Harabasz, Pearson Gamma). Default is `TRUE`.}

\item{plot_result}{Logical. Indicates whether to plot the clustering result. Default is `TRUE`.}

\item{input}{Character or in-memory dataset. A string specifying the path to a CSV file, or an in-memory
object (data frame or matrix). Default is `NULL`.
If provided, cluster assignments are appended to the observations in the original dataset,
and the updated data is stored in a package environment as 'DataAndClusters'.}
}
\value{
Invisibly returns `NULL`. If `plot_result = TRUE`, a plot of the clustering result is produced.
  If `input` is provided, the clustered dataset is stored in the package
  environment and can be retrieved with `getClusterData()`.
}
\description{
Groups similar observations using hierarchical clustering
This function is designed for clustering data types other than trained SOM models.
By default, the optimal number of clusters is determined automatically using the KGS penalty function,
but the user can also specify a fixed number of clusters.
}
\examples{
# Create a toy matrix with 9 columns and 100 rows
data <- matrix(rnorm(900), ncol = 9, nrow = 100)

# Example 1: Perform clustering directly on the matrix
clusterX(data, plot_result = TRUE)

# Example 2: Assign clusters to an in-memory data frame
df <- data.frame(
  ID = paste0("Sample", 1:100), # Character column for row headings
  matrix(rnorm(900), ncol = 9, nrow = 100) # Numeric data
)
clusterX(data, plot_result = FALSE, input = df)
getClusterData()
}
