plotArea: Plotting topics over time as stacked areas below plotted...

Description Usage Arguments Details Value Examples

View source: R/plotArea.R

Description

Creates a stacked area plot of all or selected topics.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
plotArea(
  ldaresult,
  ldaID,
  select = NULL,
  tnames = NULL,
  threshold = NULL,
  meta,
  unit = "quarter",
  xunit = "year",
  color = NULL,
  sort = TRUE,
  legend = NULL,
  legendLimit = 0,
  peak = 0,
  file
)

Arguments

ldaresult

LDA result object

ldaID

Character vector including IDs of the texts

select

Selects all topics if parameter is null. Otherwise vector of integers or topic label. Only topics belonging to that numbers, and labels respectively would be plotted.

tnames

Character vector of topic labels. It must have same length than number of topics in the model.

threshold

Numeric: Treshold between 0 and 1. Topics would only be used if at least one time unit exist with a topic proportion above the treshold

meta

The meta data for the texts or a date-string.

unit

Time unit for x-axis. Possible units are "bimonth", "quarter", "season", "halfyear", "year", for more units see round_date

xunit

Time unit for tiks on the x-axis. For possible units see round_date

color

Color vector. Color vector would be replicated if the number of plotted topics is bigger than length of the vector.

sort

Logical: Should the topics be sorted by topic proportion?

legend

Position of legend. If NULL (default), no legend will be plotted

legendLimit

Numeric between 0 (default) and 1. Only Topics with proportions above this limit appear in the legend.

peak

Numeric between 0 (default) and 1. Label peaks above peak. For each Topic every area which are at least once above peak will e labeled. An area ends if the topic proportion is under 1 percent.

file

Character: File path if a pdf should be created

Details

This function is useful to visualize the volume of topics and to show trends over time.

Value

List of two matrices. rel contains the topic proportions over time, relcum contains the cumulated topic proportions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
data(politics)
poliClean <- cleanTexts(politics)
words10 <- makeWordlist(text=poliClean$text)
words10 <- words10$words[words10$wordtable > 10]
poliLDA <- LDAprep(text=poliClean$text, vocab=words10)
LDAresult <- LDAgen(documents=poliLDA, K=10, vocab=words10)
plotArea(ldaresult=LDAresult, ldaID=names(poliLDA), meta=politics$meta)

plotArea(ldaresult=LDAresult, ldaID=names(poliLDA), meta=politics$meta, select=c(1,3,5))

## End(Not run)

tosca documentation built on Oct. 28, 2021, 5:07 p.m.