LDA topic model using R text2vec package and LDAvis in shinyApp

前端 未结 1 2025
执笔经年
执笔经年 2021-01-24 06:25

Here is the code for LDA topic modelling with R text2vec package:

library(text2vec)

tokens = docs$text %>%  # docs$text: a colection of text documents
  wo         


        
1条回答
  •  清歌不尽
    2021-01-24 07:23

    Private fields are private for a purpose - they are specifically hided for a user and not part of public API (can be easily changed in future or removed). The correct way of embedding LDAvis to a shiny app is to store LDAvis json on disk and then open it in a shiny app. Something like should work:

    lda_model$plot(out.dir = "SOME_DIR", open.browser = FALSE)
    

    And in shiny:

    output$myChart <- renderVis(readLines("SOME_DIR/lda.json"))
    

    This works because ... passed to LDAvis::createJSON and LDAvis::serVis (as documentation says):

    $plot(lambda.step = 0.1, reorder.topics = FALSE, ...)

    plot LDA model using https://cran.r-project.org/package=LDAvis package. ... will be passed to LDAvis::createJSON and LDAvis::serVis functions

    0 讨论(0)
提交回复
热议问题