
Analyze and Visualize Word Correlation Networks
Source:R/semantic_analysis.R
word_correlation_network.RdThis function creates a word correlation network based on a document-feature matrix (dfm).
Usage
word_correlation_network(
dfm_object,
doc_var = NULL,
common_term_n = 130,
corr_n = 0.4,
top_node_n = 40,
nrows = 1,
height = 1000,
width = 900,
node_label_size = 22,
community_method = "leiden",
node_size_by = "degree",
node_color_by = "community"
)Arguments
- dfm_object
A quanteda document-feature matrix (dfm).
- doc_var
A document-level metadata variable (default: NULL).
- common_term_n
Minimum number of common terms for filtering terms (default: 130).
- corr_n
Minimum correlation value for filtering terms (default: 0.4).
- top_node_n
Number of top nodes to display (default: 40).
- nrows
Number of rows to display in the table (default: 1).
- height
The height of the resulting Plotly plot, in pixels (default: 1000).
- width
The width of the resulting Plotly plot, in pixels (default: 900).
- node_label_size
Maximum font size for node labels in pixels (default: 22).
- community_method
Community detection method: "leiden" (default) or "louvain".
- node_size_by
Node sizing method: "degree", "betweenness", "closeness", "eigenvector", or "fixed" (default: "degree").
- node_color_by
Node coloring method: "community" or "centrality" (default: "community").
See also
Other semantic:
analyze_document_clustering(),
analyze_similarity_gaps(),
calculate_clustering_metrics(),
calculate_cross_similarity(),
calculate_document_similarity(),
calculate_similarity_robust(),
cluster_embeddings(),
cross_analysis_validation(),
export_document_clustering(),
extract_cross_category_similarities(),
fit_semantic_model(),
generate_cluster_labels(),
generate_cluster_labels_auto(),
generate_embeddings(),
reduce_dimensions(),
semantic_document_clustering(),
semantic_similarity_analysis(),
temporal_semantic_analysis(),
validate_cross_models(),
word_co_occurrence_network()
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_correlation_network_results <- TextAnalysisR::word_correlation_network(
dfm_object,
doc_var = NULL,
common_term_n = 30,
corr_n = 0.4,
top_node_n = 40,
nrows = 1,
height = 1000,
width = 900,
community_method = "leiden")
print(word_correlation_network_results$plot)
print(word_correlation_network_results$table)
print(word_correlation_network_results$summary)
}