Learn R Programming

textplot (version 0.2.2)

textplot_cooccurrence: Plot term cooccurrences as a network

Description

Plot term cooccurrences in a graph structure

Usage

textplot_cooccurrence(x, ...)

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

Value

an object of class ggplot

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

Examples

Run this code
# \dontshow{
if(require(udpipe) && require(igraph) && require(ggraph) && require(ggplot2))
{
# }
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")

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

Run the code above in your browser using DataLab