0

Is there a way to do topic modelling and classification on a data frame of comments in R?

I have 10 columns of comments (where each comment is a open ended sentence of a topic related to a question) and I want to classify each of these comments by topic for each column of comments.

I tried to use LDA (Latent Dirichlet Allocation) using the topicmodels package in R (and use DocumentTermMatrix and Corpus before I applied the LDA model). I tried to find the optimal number of topics using the lowest perplexity.

The issue is that I don't know what topic each sentence of a comment is classified by. It does put words into a similar topic but not by sentence. So it's a little confusing.

I don't know where to go from there and need advice on how to do this.

I was able to apply Sentimental Analysis on the same data frame in R using the sentimentr package and it worked but I can't do the same for topic modelling and classification.

How can I do this in R for each sentence of comment in a column (for a total of 10 columns)?

image of data

pete the pagan-gerbil
  • 3,136
  • 2
  • 28
  • 49
Dew Man
  • 35
  • 2
  • 5
  • Are you able to provide a minimal set of data to reproduce the problem that you're having and include it in the question? – pete the pagan-gerbil Jul 15 '20 at 14:56
  • Hey. I added the image of my dataset now – Dew Man Jul 15 '20 at 20:09
  • Images of data can't be reproduced, which is likely why you didn't get an answer. Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269). This will make it much easier for others to help you. – JBGruber Jul 23 '20 at 12:25

0 Answers0