% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cluster_data.R
\name{cluster_network}
\alias{cluster_network}
\title{Cluster data and build per-cluster networks in one step}
\usage{
cluster_network(data, k, cluster_by = "pam", dissimilarity = "hamming", ...)
}
\arguments{
\item{data}{Sequence data. Accepts a data frame, matrix, or
\code{netobject}. See \code{\link{build_clusters}} for supported formats.}

\item{k}{Integer. Number of clusters.}

\item{cluster_by}{Character. Clustering algorithm passed to
\code{\link{build_clusters}}'s \code{method} parameter (\code{"pam"},
\code{"ward.D2"}, \code{"ward.D"}, \code{"complete"}, \code{"average"},
\code{"single"}, \code{"mcquitty"}, \code{"median"}, \code{"centroid"}),
or \code{"mmm"} for Mixed Markov Model clustering. Default: \code{"pam"}.}

\item{dissimilarity}{Character. Distance metric for sequence clustering
(ignored when \code{cluster_by = "mmm"}). Default: \code{"hamming"}.}

\item{...}{Passed directly to \code{\link{build_network}}. Use
\code{method} to specify the network type; \code{threshold},
\code{scaling}, and all other \code{build_network} arguments are
supported.}
}
\value{
A \code{netobject_group}.
}
\description{
Combines sequence clustering and network estimation into a single call.
Clusters the data using the specified algorithm, then calls
\code{\link{build_network}} on each cluster subset.
}
\details{
If \code{data} is a \code{netobject} and \code{method} is not provided in
\code{...}, the original network method is inherited automatically so the
per-cluster networks match the type of the input network.
}
\examples{
seqs <- data.frame(V1 = c("A","B","C","A","B"), V2 = c("B","C","A","B","A"),
                   V3 = c("C","A","B","C","B"))
grp <- cluster_network(seqs, k = 2)
grp
\donttest{
seqs <- data.frame(
  V1 = sample(LETTERS[1:4], 50, TRUE), V2 = sample(LETTERS[1:4], 50, TRUE),
  V3 = sample(LETTERS[1:4], 50, TRUE), V4 = sample(LETTERS[1:4], 50, TRUE)
)
# Default: PAM clustering, relative (transition) networks
grp <- cluster_network(seqs, k = 3)

# Specify network method (cor requires numeric panel data)
\dontrun{
panel <- as.data.frame(matrix(rnorm(1500), nrow = 300, ncol = 5))
grp <- cluster_network(panel, k = 2, method = "cor")
}

# MMM-based clustering
grp <- cluster_network(seqs, k = 2, cluster_by = "mmm")
}
}
\seealso{
\code{\link{build_clusters}}, \code{\link{cluster_mmm}},
\code{\link{build_network}}
}
