Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mshin77 committed Feb 6, 2024
1 parent 700a23e commit 0344fb7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
27 changes: 27 additions & 0 deletions inst/TextAnalysisR.app/markdown/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- README.md is generated from README.Rmd. Please edit that file -->
<!-- badges: start -->

[![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()
12 changes: 5 additions & 7 deletions inst/TextAnalysisR.app/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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")
}
})

mydata <- reactive({
if (input$dataset_choice == "Upload an Example Dataset") {
if (input$dataset_choice == "SpecialEduTech") {
data <- TextAnalysisR::SpecialEduTech
} else {
req(input$file)
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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()))
})
Expand Down Expand Up @@ -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) +
Expand Down
11 changes: 6 additions & 5 deletions inst/TextAnalysisR.app/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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"))
)
),
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 0344fb7

Please sign in to comment.