R скрипт на блестящем сервере, вызывающий несколько ошибок - PullRequest
0 голосов
/ 03 июня 2019

Я пытаюсь создать приложение для анализа в твиттере.

Логика заключается в том, что как только введен поисковый термин и нажата кнопка действия, все готово.

Однако в этом случае ничего не делается, вместо этого появляется сообщение об ошибке.

есть функция поиска в твиттере, которая возвращает df с 1 столбцом, помеченным текстом, это столбец, который я пытаюсь очистить и работать над

ui <- fluidPage(

  fluidRow( 
    column( 4, titlePanel("Twitter Analytics")),
    column( 3),
    column( 4, 
            textInput("searchstring", 
                      label = "",
                      value = "")),
    column(1, 
           br(),
           actionButton("action", "go"))
  ),
  fluidRow(
    column( 12, tabsetPanel(
      tabPanel("one",
               fluidRow(
                 column(3 ),
                 column(9,  plotOutput("ttext"))
                 )
         ),    
    tabPanel("two"),
    tabPanel("three"), 
    tabPanel("DataTable",
             fluidRow(
               column(12, dataTableOutput("mysearch") 
               )
             )
           )
         )
       )
     )
   )

server <- function(input, output) {

  twitter <- eventReactive(input$action,{
    search_tweets( input$searchstring , n = 50, include_rts = FALSE)

  })

  output$mysearch  <- renderDataTable({
    twitter()
  }) 
  output$ttext <- renderUI({ 
    df <- twitter()
    df<- as.data.frame(df)
    df$text = tolower(df$text)
    # # Replace @UserName
    df$text <- gsub("@\\w+", "", df$text)
    # #remove punctuation
    df$text <- gsub("[[:punct:]]", "", df$text)
    # #remove links
    df$text <- gsub("http\\w+", "", df$text)
    # # Remove tabs
    df$text <- gsub("[ |\t]{2,}", "", df$text)
    # # Remove blank spaces at the beginning
    df$text <- gsub("^ ", "", df$text)
    # # Remove blank spaces at the end
    df$text <- gsub(" $", "", df$text)
    corpus <- iconv(df$text, to = "ASCII")
    corpus <- Corpus(VectorSource(corpus))
    corpus <- tm_map(corpus, removePunctuation)
    corpus <- tm_map(corpus, removeNumbers)
    cleanset <- tm_map(corpus, removeWords, stopwords('english'))
    cleanset <- tm_map(cleanset, stripWhitespace)
    tdm <- TermDocumentMatrix(cleanset)
    tdm <- as.matrix(tdm)
    w <- rowSums(tdm)
    w<- subset(w, w>=13)
    barplot(w, 
            main="Word Frequency in Sri Lanka Tweetset",
            las = 2,
            col = brewer.pal(n = n, name = "YlGnBu"))
  })
}

shinyApp(ui, server)

Я получаю эти ошибки, когда запускаю код в rstudio и глянцевый, в rstudio это не мешает мне делать что-либо, хотя блестящий просто закрывается, любая помощь приветствуется

Finished collecting tweets!
Warning in tm_map.SimpleCorpus(corpus, removePunctuation) :
  transformation drops documents
Warning in tm_map.SimpleCorpus(corpus, removeNumbers) :
  transformation drops documents
Warning in tm_map.SimpleCorpus(corpus, removeWords, stopwords("english")) :
  transformation drops documents
Warning in tm_map.SimpleCorpus(cleanset, stripWhitespace) :
  transformation drops documents
Warning: Error in <: comparison (3) is possible only for atomic and list types
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...