From 0344fb7002464d12a82d1e74c630353a04796da0 Mon Sep 17 00:00:00 2001 From: Mikyung Shin Date: Mon, 5 Feb 2024 19:41:11 -0600 Subject: [PATCH] fix errors --- inst/TextAnalysisR.app/markdown/about.md | 27 ++++++++++++++++++++++++ inst/TextAnalysisR.app/server.R | 12 +++++------ inst/TextAnalysisR.app/ui.R | 11 +++++----- 3 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 inst/TextAnalysisR.app/markdown/about.md diff --git a/inst/TextAnalysisR.app/markdown/about.md b/inst/TextAnalysisR.app/markdown/about.md new file mode 100644 index 0000000..5e6ff3c --- /dev/null +++ b/inst/TextAnalysisR.app/markdown/about.md @@ -0,0 +1,27 @@ + + + +[![R-CMD-check](https://github.com/mshin77/TextAnalysisR/workflows/R-CMD-check/badge.svg)](https://github.com/mshin77/TextAnalysisR/actions) + +`TextAnalysisR` provides a supporting workflow for text mining analysis. +The web app incorporates +[quanteda](https://github.com/quanteda/quanteda) (text preprocessing), +[stm](https://github.com/bstewart/stm) (structural topic modeling), and +[ggraph](https://github.com/thomasp85/ggraph) as well as +[widyr](https://github.com/juliasilge/widyr) (network analysis). +[tidytext](https://github.com/cran/tidytext) was implemented to tidy +non-tidy format objects. + +## Installation + +The development version from [GitHub](https://github.com/) with: + + install.packages("devtools") + devtools::install_github("mshin77/TextAnalysisR") + +## Example + +Launch and browser the TextAnalysisR app: + + library(TextAnalysisR) + TextAnalysisR.app() diff --git a/inst/TextAnalysisR.app/server.R b/inst/TextAnalysisR.app/server.R index 7814793..4b7fc2e 100644 --- a/inst/TextAnalysisR.app/server.R +++ b/inst/TextAnalysisR.app/server.R @@ -15,7 +15,7 @@ suppressPackageStartupMessages({ server <- shinyServer(function(input, output, session) { observe({ - if (input$dataset_choice == "Upload an Example Dataset") { + if (input$dataset_choice == "SpecialEduTech") { shinyjs::disable("file") } else { shinyjs::enable("file") @@ -23,7 +23,7 @@ server <- shinyServer(function(input, output, session) { }) mydata <- reactive({ - if (input$dataset_choice == "Upload an Example Dataset") { + if (input$dataset_choice == "SpecialEduTech") { data <- TextAnalysisR::SpecialEduTech } else { req(input$file) @@ -170,10 +170,12 @@ server <- shinyServer(function(input, output, session) { }) # Remove common words across documents - dfm_outcome <- eventReactive(input$remove, { + dfm_outcome <- reactive({ dictionary_list_1 <- TextAnalysisR::dictionary_list_1 dictionary_list_2 <- TextAnalysisR::dictionary_list_2 + print(input$remove) + rm <- isolate(input$remove.var) if (!is.null(rm)) { @@ -331,7 +333,6 @@ server <- shinyServer(function(input, output, session) { # 2. Step 2: Run a model and display highest word probabilities for each labeled topic - output$K_number_uiOutput <- renderUI({ sliderInput( "K_number", @@ -445,7 +446,6 @@ server <- shinyServer(function(input, output, session) { # Display highest word probabilities for each topic # Tidy the word-topic combinations - beta_td <- reactive({ tidytext::tidy(stm_K_number(), document_names = rownames(dfm_outcome())) }) @@ -486,9 +486,7 @@ server <- shinyServer(function(input, output, session) { topic_term_plot$topic = factor(topic_term_plot$topic, levels = topic_term_plot$topic %>% unique()) } - topic_term_plot$tt = NULL - topic_term_plot %>% ggplot(aes(term, beta, fill = topic)) + geom_col(show.legend = FALSE, alpha = 0.8) + diff --git a/inst/TextAnalysisR.app/ui.R b/inst/TextAnalysisR.app/ui.R index 70174ef..2d7f193 100644 --- a/inst/TextAnalysisR.app/ui.R +++ b/inst/TextAnalysisR.app/ui.R @@ -38,7 +38,7 @@ ui <- fluidPage( tabPanel("TextAnalysisR", navlistPanel( widths = c(3, 9), - tabPanel("About", includeMarkdown("markdown/README.md")) + tabPanel("About", includeMarkdown("markdown/about.md")) )), tabPanel("Upload", sidebarLayout( @@ -48,7 +48,7 @@ ui <- fluidPage( "dataset_choice", "Upload a file or use the dataset", selected = " ", - choices = c(" ", "Upload an Example Dataset", "Upload Your File") + choices = c(" ", "SpecialEduTech", "Upload Your File") ), fileInput( @@ -110,7 +110,8 @@ ui <- fluidPage( "remove.var", "Remove common words.", choices = NULL, - options = list(maxItems = 20)), + options = list(maxItems = 20) + ), actionButton("remove", "Remove", icon = icon("minus-circle")) ) ), @@ -167,9 +168,9 @@ ui <- fluidPage( sliderInput( "K_range_1", "Range of topic numbers", - value = c(2, 10), + value = c(5, 30), min = 0, - max = 50 + max = 100 ), selectizeInput( "categorical_var",