| plotTopic | R Documentation |
Creates a plot of the counts/proportion of specified topics of a result of
LDAgen. There is an option to plot all curves in one plot
or to create one plot for every curve (see pages).
In addition the plots can be written to a pdf by setting file.
plotTopic(
object,
ldaresult,
ldaID,
select = 1:nrow(ldaresult$document_sums),
tnames,
rel = FALSE,
mark = TRUE,
unit = "month",
curves = c("exact", "smooth", "both"),
smooth = 0.05,
main,
xlab,
ylim,
ylab,
both.lwd,
both.lty,
col,
legend = ifelse(pages, "onlyLast:topright", "topright"),
pages = FALSE,
natozero = TRUE,
file,
...
)
object |
|
ldaresult |
The result of a function call |
ldaID |
Character vector of IDs of the documents in
|
select |
Integer: Which topics of
|
tnames |
Character vector of same length as |
rel |
Logical: Should counts ( |
mark |
Logical: Should years be marked by
vertical lines (default: |
unit |
Character: To which unit should dates be floored
(default: |
curves |
Character: Should |
smooth |
Numeric: Smoothing parameter
which is handed over to |
main |
Character: Graphical parameter |
xlab |
Character: Graphical parameter |
ylim |
Graphical parameter |
ylab |
Character: Graphical parameter |
both.lwd |
Graphical parameter for smoothed values
if |
both.lty |
Graphical parameter for smoothed values
if |
col |
Graphical parameter, could be a vector. If |
legend |
Character: Value(s) to specify the legend coordinates (default: |
pages |
Logical: Should all curves be
plotted in a single plot (default: |
natozero |
Logical: Should NAs be coerced
to zeros (default: |
file |
Character: File path if a pdf should be created |
... |
Additional graphical parameters |
A plot.
Invisible: A dataframe with columns date and tnames with the
counts/proportion of the selected topics.
## 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)
# plot all topics
plotTopic(object=poliClean, ldaresult=LDAresult, ldaID=names(poliLDA))
# plot special topics
plotTopic(object=poliClean, ldaresult=LDAresult, ldaID=names(poliLDA), select=c(1,4))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.