% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/unsupervised-validation.R
\name{tidy_gap_stat}
\alias{tidy_gap_stat}
\title{Tidy Gap Statistic}
\usage{
tidy_gap_stat(data, FUN_cluster = NULL, max_k = 10, B = 50, nstart = 25)
}
\arguments{
\item{data}{A data frame or tibble}

\item{FUN_cluster}{Clustering function (default: uses kmeans internally)}

\item{max_k}{Maximum number of clusters (default: 10)}

\item{B}{Number of bootstrap samples (default: 50)}

\item{nstart}{If using kmeans, number of random starts (default: 25)}
}
\value{
A list of class \code{"tidy_gap"} containing:
\itemize{
\item gap_data: tibble with gap statistics for each k
\item k_firstSEmax: optimal k via firstSEmax method (most conservative)
\item k_globalmax: optimal k via globalmax method
\item k_firstmax: optimal k via firstmax method
\item recommended_k: recommended k (uses firstSEmax)
\item model: the \code{\link[cluster]{clusGap}} result
}
}
\description{
Compute gap statistic for determining optimal number of clusters
}
\examples{
\donttest{
gap <- tidy_gap_stat(iris[, 1:4], max_k = 6, B = 10)
gap$recommended_k
}

}
