textplot_cooccurrence: Plot term cooccurrences as a network

View source: R/textplot_cooccurrence.R

textplot_cooccurrenceR Documentation

Plot term cooccurrences as a network

Description

Plot term cooccurrences in a graph structure

Usage

textplot_cooccurrence(x, ...)

## Default S3 method:
textplot_cooccurrence(
  x,
  terms,
  top_n = 50,
  title = "Term cooccurrences",
  subtitle = list(),
  vertex_color = "darkgreen",
  edge_color = "grey",
  base_family = "",
  ...
)

Arguments

x

a data.frame with columns term1, term2 and cooc indicating how many times 2 terms are occurring together

...

other parameters passed on to ggraph::geom_node_text

terms

a character vector with terms to only plot. Prevails compared to using top_n

top_n

integer indicating to show only the top n occurrences as in head(x, n = top_n)

title

character string with the title to use in the plot

subtitle

character string with the subtitle to use in the plot

vertex_color

character with the color of the label of each node. Defaults to darkgreen.

edge_color

character with the color of the edges between the nodes. Defaults to grey.

base_family

character passed on to theme_void setting the base font family

Value

an object of class ggplot

Examples


library(udpipe)
library(igraph)
library(ggraph)
library(ggplot2)
data(brussels_reviews_anno, package = 'udpipe')
x <- subset(brussels_reviews_anno, xpos %in% "JJ" & language %in% "fr")
x <- cooccurrence(x, group = "doc_id", term = "lemma")

textplot_cooccurrence(x, top_n = 25, subtitle = "showing only top 25")
textplot_cooccurrence(x, top_n = 25, title = "Adjectives",
                      vertex_color = "orange", edge_color = "black",
                      fontface = "bold")



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