Lexical Dispersion Plot
plotLexDiv.Rd
The function creates a lexical dispersion plot for corpus objects based on keywords or dictionaries.
Usage
plotLexDiv(corpus,
keywords,
docvar=NULL,
value=NULL,
aggr.by.var=NULL,
rem.accent = TRUE,
rem.punct = TRUE,
case.insensitive = TRUE,
lang = "es",
title="Lexical Dispersion Plot",
caption="Own elaboration.",
subtitle="Keywords",
legend.title="Group",
legend.rows=1,
palette=c("#DD8D29","#E2D200","#46ACC8","#E58601","#B40F20"),
custom.color="black",
panel.bg.fill="grey98",
hline.color="white",
hline.width=0.5,
na.rm=FALSE)
Arguments
- corpus
A quanteda corpus object.
- keywords
Keywords or dictionary employed to search for terms in texts.
- docvar
Metadata variable associated to the texts on a quanteda corpus object.
- value
List of values contained in the metadata variable (docvar).
- aggr.by.var
Establish the grouping variable to be used in the creation of a new aggregated corpus.
- rem.accent
Remove accents. The default is TRUE.
- rem.punct
Remove punctuation. The default is TRUE.
- case.insensitive
Search for both upper and lowercase words. The default is TRUE.
- lang
The language for removing stopwords. The default is Spanish: "es".
- title
The title of the graph. The default ist "Lexical Dispersion Plot".
- caption
The caption, note or source of the graph. The default is "Own elaboration".
- subtitle
The subtitle of the graph. The default is "Keywords".
- legend.title
The title for the legend. The default is "Group".
- legend.rows
The number of rows organizing groups in the legend. The default is 1.
- palette
The list of color names of hexadecimal codes to represent groups.
- custom.color
The custom color to be used when no groups or dictionary entries are defined. The default is "black".
- panel.bg.fill
The background color for the text panels. The default color is "grey98".
- hline.color
Horizontal line color. The default is "white".
- hline.width
Horizontal line width. The default is 0.5.
- na.rm
Logical. Removes texts that do not contain the keywords or categories indicated. The default is FAlSE.
Details
The function generates a Lexical Dispersion Plot for keywords, dictionaries or metadata variables. It represents the position of the selected keywords, dictionary categories, or metadata values in each text forming a corpus object.
Examples
if (FALSE) {
# Retrieve a corpus of text
tx <- quanteda::data_corpus_inaugural
# find the relative position of keywords
plotLexDiv(tx, keywords = c("democ","liber","freedom"))
# creates a dictionary
dic <- dictionary(list(
Goverment=c("govern",
"executive",
"policy"),
Nation=c("nation",
"homeland",
"patriot"),
Democracy=c("democ",
"freedom",
"liberty",
"rights")
))
# Creates the graph
plotLexDiv(tx,
keywords = dic)
# Aggregate the corpus according to party
plotLexDiv(tx,
docvar="President",
value=c("Nixon","Bush","Kennedy","Roosevelt"),
aggr.by.var = "Party")
}