textplot_correlation_glasso: Plot sparse term correlations as a graph structure

View source: R/textplot_corglasso.R

textplot_correlation_glassoR Documentation

Plot sparse term correlations as a graph structure

Description

Plot sparse term correlations as a graph structure. Uses the glasso procedure (glasso::glassopath) to reduce the correlation matrix to retain only the relevant correlations and next visualises these sparse correlations.

Usage

textplot_correlation_glasso(x, ...)

## Default S3 method:
textplot_correlation_glasso(
  x,
  n = 1000,
  exclude_zero = TRUE,
  label.cex = 1,
  node.width = 0.5,
  ...
)

Arguments

x

a correlation matrix

...

further arguments passed on to qgraph::qgraph, except layout which is set to 'spring', labels (taken from the colnames of x), and borders which is set to FALSE.

n

sample size used in computing the sparse correlation matrix. Defaults to 1000.

exclude_zero

logical indicating to exclude zero-correlations from the graph

label.cex

passed on to qgraph::qgraph

node.width

passed on to qgraph::qgraph

Value

an object of class ggplot

Examples


library(udpipe)
library(qgraph)
library(glasso)
data(brussels_reviews_anno, package = 'udpipe')
x <- subset(brussels_reviews_anno, xpos %in% "NN" & language %in% "fr" & !is.na(lemma))
x <- document_term_frequencies(x, document = "doc_id", term = "lemma")
dtm <- document_term_matrix(x)
dtm <- dtm_remove_lowfreq(dtm, maxterms = 60)

m <- dtm_cor(dtm)
textplot_correlation_glasso(m, exclude_zero = TRUE)

textplot_correlation_glasso(m, exclude_zero = FALSE)




textplot documentation built on July 18, 2022, 1:05 a.m.