% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/semantic_analysis.R
\name{word_co_occurrence_network}
\alias{word_co_occurrence_network}
\title{Analyze and Visualize Word Co-occurrence Networks}
\usage{
word_co_occurrence_network(
  dfm_object,
  doc_var = NULL,
  co_occur_n = 50,
  edge_metric = c("count", "pmi"),
  top_node_n = 30,
  nrows = 1,
  height = 800,
  width = 900,
  node_label_size = 22,
  community_method = "leiden",
  node_size_by = "degree",
  node_color_by = "community",
  seed = 123,
  category_params = NULL
)
}
\arguments{
\item{dfm_object}{A quanteda document-feature matrix (dfm).}

\item{doc_var}{A document-level metadata variable (default: NULL).}

\item{co_occur_n}{Minimum co-occurrence count (default: 50). A heuristic
default; vary it to check edge-count sensitivity.}

\item{edge_metric}{Edge weight: "count" (default, raw co-occurrence) or
"pmi" (pointwise mutual information, correcting the bias toward generic
high-frequency words; only positive-PMI pairs are kept).}

\item{top_node_n}{Number of top nodes to display (default: 30).}

\item{nrows}{Number of rows to display in the table (default: 1).}

\item{height}{The height of the resulting Plotly plot, in pixels (default: 800).}

\item{width}{The width of the resulting Plotly plot, in pixels (default: 900).}

\item{node_label_size}{Maximum font size for node labels in pixels (default: 22).}

\item{community_method}{Community detection method: "leiden" (default) or "louvain".}

\item{node_size_by}{Node sizing method: "degree", "betweenness", "closeness", "eigenvector", or "fixed" (default: "degree").}

\item{node_color_by}{Node coloring method: "community" or "centrality" (default: "community").}

\item{seed}{Integer seed for the force-directed layout, so the plot is reproducible (default: 123).}

\item{category_params}{Optional named list of category-specific parameters. Each element should be a list with \code{co_occur_n} and \code{top_node_n} values for that category (default: NULL).}
}
\value{
A list containing the ggplot2 plot, a table, and a summary.
}
\description{
This function creates a word co-occurrence network based on a document-feature matrix (dfm).
}
\examples{
if (interactive()) {
  df <- TextAnalysisR::SpecialEduTech

  united_tbl <- TextAnalysisR::unite_cols(df, listed_vars = c("title", "abstract"))

  tokens <- TextAnalysisR::prep_texts(united_tbl, text_field = "united_texts")

  dfm_object <- quanteda::dfm(tokens)

  word_co_occurrence_network_results <- TextAnalysisR::word_co_occurrence_network(
                                        dfm_object,
                                        doc_var = NULL,
                                        co_occur_n = 50,
                                        top_node_n = 30,
                                        nrows = 1,
                                        height = 800,
                                        width = 900,
                                        community_method = "leiden")
  print(word_co_occurrence_network_results$plot)
  print(word_co_occurrence_network_results$table)
  print(word_co_occurrence_network_results$summary)
}
}
\seealso{
Other semantic:
\code{\link[=word_correlation_network]{word_correlation_network()}}
}
\concept{semantic}
