Skip to contents

This function creates a word co-occurrence network based on a document-feature matrix (dfm).

Usage

word_co_occurrence_network(
  dfm_object,
  doc_var = NULL,
  co_occur_n = 50,
  top_node_n = 30,
  nrows = 1,
  height = 800,
  width = 900
)

Arguments

dfm_object

A quanteda document-feature matrix (dfm).

doc_var

A document-level metadata variable (default: NULL).

co_occur_n

Minimum number of co-occurrences for filtering terms (default: 50).

top_node_n

Number of top nodes to display (default: 30).

nrows

Number of rows to display in the table (default: 1).

height

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

width

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

Value

A list containing the Plotly plot, a data frame of the network layout, and the igraph graph object.

Examples

if (interactive()) {
  df <- TextAnalysisR::SpecialEduTech

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

  tokens <- TextAnalysisR::preprocess_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 = "reference_type",
                                        co_occur_n = 50,
                                        top_node_n = 30,
                                        nrows = 1,
                                        height = 800,
                                        width = 900)
  print(word_co_occurrence_network_results$plot)
  print(word_co_occurrence_network_results$table)
  print(word_co_occurrence_network_results$summary)
}