plotArea {tosca} | R Documentation |
Plotting topics over time as stacked areas below plotted lines.
Description
Creates a stacked area plot of all or selected topics.
Usage
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 |
xunit |
Time unit for tiks on the x-axis. For possible units see |
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 |
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 |
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
## 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)