Learn R Programming

textplot (version 0.2.2)

textplot_correlation_glasso: 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, ...)

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

Value

an object of class ggplot

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

Examples

Run this code
# \dontshow{
if(require(udpipe) && require(qgraph) && require(glasso))
{
# }
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)
# \donttest{
textplot_correlation_glasso(m, exclude_zero = FALSE)
# }

# \dontshow{
}
# End of main if statement running only if the required packages are installed
# }

Run the code above in your browser using DataLab