topicsInText {tosca} | R Documentation |
Coloring the words of a text corresponding to topic allocation
Description
The function creates a HTML document with the words of texts colored depending on the topic allocation of each word.
Usage
topicsInText(
text,
ldaID,
id,
ldaresult,
label = NULL,
vocab,
wordOrder = c("both", "alphabetical", "topics", ""),
colors = NULL,
fixColors = FALSE,
meta = NULL,
originaltext = NULL,
unclearTopicAssignment = TRUE,
htmlreturn = FALSE
)
Arguments
text |
The result of |
ldaID |
List of IDs for |
id |
ID of the article of interest |
ldaresult |
A result object from the |
label |
Optional label for each topic |
vocab |
Character: Vector of |
wordOrder |
Type of output: |
colors |
Character vector of colors. If the vector is shorter than the number of topics it will be completed by "black" entrys. |
fixColors |
Logical: If |
meta |
Optional input for meta data. It will be printed in the header of the output. |
originaltext |
Optional a list of texts (the |
unclearTopicAssignment |
Logical: If TRUE all words which are assigned to more than one topic will not be colored. Otherwise the words will be colored in order of topic apperance in the |
htmlreturn |
Logical: HTML output for tests |
Value
A HTML document
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)
topicsInText(text=politics$text, ldaID=names(poliLDA), id="ID2756",
ldaresult=LDAresult, vocab=words10)
## End(Not run)