Ошибка в Rshiny Ошибка в наследует: аргумент "FUN" отсутствует, по умолчанию нет - PullRequest
0 голосов
/ 19 октября 2019

Попытка создать Wordcloud из текстового документа с помощью RShiny (включая Text Mining Code). Когда я выполнил эту команду, я получил следующую ошибку: Ошибка в наследовании: отсутствует аргумент "FUN" без значения по умолчанию

library("arules")
library("devtools")
library("tm")
library("textclean")
library("katadasaR")
library("tokenizers")
library("wordcloud")
library("stringr")
library("dplyr")
library("SnowballC")
library("arulesViz")
require(katadasaR)

library(shiny)

ui = fluidPage(# theme = "bootstrap.css",

# Application title
  titlePanel(windowTitle = "A4MD-Association Rule Mining", 
             title = div(
               column(3, img(src = 'task2_logo2.png', width = '30%')),
               column(12, h1('A4MD: Association Analysis for Machine Damage'))
                )
                ),
                hr(),
                br(),

  tabsetPanel( 
  tabPanel("User Guide",
         br(),
          sidebarLayout(
            sidebarPanel(width = 3,
            h2("Instalasi", align = "center"),
            h4("Shiny tersedia di CRAN,", align = "center",br(),"Instal di R Console PC-mu!"),align = "center", 
            br(),
            br(),
            br(),
            img(src = "Rstudio.png", width= '90%', style="display: block; margin-left: auto; margin-right: auto;"),
            h4("Shiny is a produck of", align = "center"), h4(a(href="", "Rstudio"),align = "center") 
            ),

            mainPanel(
              h2("Panduan Penggunaan Aplikasi"),
              hr(),

              h4("DESKRIPSI"),
              "- Aplikasi ini digunakan untuk menemukan dan menganalisis asosiasi kerusakan pada mesin industri.", br(),
              "- Pola-pola asosiasi kerusakan mesin digali dari kumpulan data-data historis kerusakan mesin.", br(),
              hr(),

              h4("LICENSI"),
              "- Aplikasi ini", br(),
              hr(),

              h4("FORMAT DATA"),
              "- Data yang diinput harus berformat.",strong(".CSV"),  br()
            )
            )),   

    tabPanel("Data Visualization",
             br(),

             #Sidebar with file input 
             sidebarLayout(
               sidebarPanel(width = 3,
                 fileInput(inputId = "data1", label = "Input your file!", buttonLabel = "Browse...",
                           placeholder = "No file selected"),
                 selectInput(inputId = 'dropdown', label = 'Choose separator', 
                             choices = c('Comma' = ',','Semicolon' = ';')),
                 checkboxInput(inputId = 'data2', label = "Checklist if you want to read first row as column's name!"),
                 br(),
                 downloadButton(outputId = 'dwn', label = 'Download Data')
              ),

               # OUTPUT DISPLAY
               mainPanel(tableOutput(outputId = "value"))
              )
              ),


    tabPanel("Data Dimension Reduction",
             br(),

             #Sidebar with file input 
             sidebarLayout(
               sidebarPanel(width = 3,
                 selectInput(inputId = 'dropdown_column', label = "Choose column's name!",choices = c('')),
                 sliderInput("spr", "Sparse Number", 1,50,50),
                 actionButton("up", "Check Sparsity")
               ),

               # OUTPUT DISPLAY
               mainPanel(plotOutput("sparsity")
             )
            )),

    tabPanel("Word Frequency", "contents"),
    tabPanel("Wordclouds", "contents"),
    tabPanel("Rule Mining", "contents"),
    tabPanel("Rule Visualization", "contents")

    ))

server = function(input, output, session){
  output$dwn = downloadHandler(
    filename = function(){
      paste('Download', Sys.Date(), sep = '_')
    },
    content = function(downloadfolder){
      write.csv(iris, downloadfolder, row.names = FALSE)
      #file.copy('task2_logo.PNG',con)
      })

  x = reactive({
    if(is.null(input$data1)){ # R will not read data if it has not been uploaded
      return('Input your dataset')
    }
    read.csv(file = input$data1$datapath, header = input$data2, sep = input$dropdown) 
    })
  observe({
    rm = names(x())
    updateSelectInput(session = session, inputId = 'dropdown_column', choices = rm)
    })

  output$value = renderTable({
    # INPUT FOR data1
    x()
    })

  #OUTPUT DDR

  wc = reactive({
    input$up

    isolate({
      withProgress({
      setProgress(message = "Processing corpus...")
    wcf <- input$data1
      if (!is.null(wcf)){
        dataClean = readLines(wcf$datapath)
      }
      else {
        return("A word cloud is a image made of words that together resemble a cloudy shape.
               The size word shows how important is e.g. how often it appears in a text- its frequency. 
               People typically use word cloud to easily produce a summary of a large document")
      }
      #Codingan Text Mining

    #Text Preprocessing
    # 1. Case Folding
    myCorpus       <- Corpus(VectorSource(dataClean))
    myCorpus       <- tm_map(myCorpus, tolower)

    # 2. Tokenizing and Stopwords Removal
    myStopword     <- readLines("bahasa_stopwords.txt")
    dataClean      <- dataClean %>%
      tokenize_words(stopwords = myStopword)

    # 3. Stemming
     stemming       <- function(x) {
      paste(lapply(x, katadasaR), collapse = " ")
    }

    dataClean      <- lapply(dataClean, stemming)

    # Term Frequent and Text Representation
    # 1. Create a Term-Document Matrix (TDM)
    myCorpus       <- Corpus(VectorSource(dataClean))
    tfidf          <- tm_map(myCorpus,
                             control = list(removePunctuation = TRUE,
                                            stopwords = FALSE,
                                            tolower = FALSE,
                                            stemming = FALSE,
                                            removeNumbers = FALSE,
                                            removePunctuation = TRUE,
                                            stripWhitespace = TRUE))
    # Term Weighting (TF-IDF)
    TFIDF      <- weightTfIdf(tfidf)

    # Reduksi Dimensi Data
    dtm        <- removeSparseTerms(tfidf, 0.99)
    weightTfIdf(tfidf)


    })

    })
  })

  wordcloud_rep <- repeatable(wordcloud())
  output$sparsity <- renderPlot({
    withProgress({
      setProgress(message = "Creating Wordcloud...")
      wdata <- wc()
      wordcloud(wdata, min.freq = input$spr, scale = c(4,1),random.order = TRUE,
                rot.per = 0.35, use.r.layout = FALSE, colors = brewer.pal(8,"Dark2"))
    })
  })


}

# Read R Script become R Shiny Script
shinyApp(ui = ui, server = server)

Я пробовал различные методы, но он все еще делаетне работает, и я прочитал, связанные с воспроизводимыми примерами, но не понимаю.

Пожалуйста, кто-нибудь Помогите мне,

Спасибо

...