
Last chance! 50% off unlimited learning
Sale ends in
The function creates a HTML document with the words of texts colored depending on the topic allocation of each word.
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
)
A HTML document
The result of LDAprep
List of IDs for text
ID of the article of interest
A result object from the standardLDA
Optional label for each topic
Character: Vector of vocab
corresponding to the text
object
Type of output: "alphabetical"
prints the words of the article in alphabetical order, "topics"
sorts by topic (biggest topic first) and "both"
prints both versions. All other inputs will result to no output (this makes only sense in combination with originaltext
.
Character vector of colors. If the vector is shorter than the number of topics it will be completed by "black" entrys.
Logical: If FALSE
the first color will be used for the biggest topic and so on. If fixColors=TRUE
the the color-entry corresponding to the position of the topic is choosen.
Optional input for meta data. It will be printed in the header of the output.
Optional a list of texts (the text
list of the textmeta
object) including the desired text. Listnames must be IDs. Necessary for output in original text
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 ldaresult
.
Logical: HTML output for tests
if (FALSE) {
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)}
Run the code above in your browser using DataLab