Reputation: 3897
I'm using the text-mining tm
library for R.
I'm running on R version 3.3.1
I have this code:
lda <- LDA(docterm,k = 3,method = 'Gibbs')
lda.topics <- as.matrix(topics(lda))
lda.terms <- as.matrix(terms(lda,5))
topic.terms <- c()
topic.terms[1] <- paste(c(lda.terms[,1],'\n'),collapse = '\n')
topic.terms[2] <- paste(c(lda.terms[,2],'\n'),collapse = '\n')
topic.terms[3] <- paste(c(lda.terms[,3],'\n'),collapse = '\n')
tw.df <- tw.df %>%
mutate(topico = topic.terms[lda.topics])
But every time I try to run it with source file.r
It throws me this:
Error in eval(expr, envir, enclos) : could not find function "LDA"
I don't get it, the tm
package is installed.
Has anybody encountered this kind of behaviour before?
Any ideas on how to solve it?
Thanks in advance!
Upvotes: 4
Views: 9075
Reputation: 96
Try installing and using the package 'topicmodels'.
install.packages('topicmodels')
It should work.
Upvotes: 2