0

I am trying to build an app for data cleaning text data.

Once their file is uploaded the cleaning options appear (I stripped it out from this example code because that works already perfectly) and I want users to clean their data based on clickable options, so with checkboxInputs, and one selctizeInput (that pulls all words out of the file and you can pick which other words to remove from the dataset). It should all run once an action button is clicked. I have build a first "if" in the server, assuming all are clicked.

However it does nothing in my actual app. I am not sure where the actual mistake is, but have a feeling there are a few.

Any help much appreciated!

 ui:
 checkboxInput("clean1", label = "Remove Punctuation", value = TRUE),
 checkboxInput("clean2", label = "Remove Numbers", value = TRUE),
 checkboxInput("clean3", label = "Convert to lower case", value = TRUE),
 selectizeInput(
  'removeWords', 'Remove also these words', multiple = TRUE, choices = filebywords$words),
   actionButton("preprocessing", "Clean up my data")


  server: 
  cleandata <- eventReactive(input$preprocessing, {


  if (input$clean1==TRUE && 
  input$clean2==TRUE && 
  input$clean3==TRUE && ) 
{

  df <- filedata()
  docs <- Corpus(DirSource(df))   

  # clean 1 function
  docs <- tm_map(docs, removePunctuation)   

  #clean 2 function
  docs <- tm_map(docs, removeNumbers) 

  #clean 3 function
  docs <- tm_map(docs, tolower)   

  # selctizeInput  words
  toremovedwords <- reactive({
    str(sapply(sprintf('removeWords'), function(id) {
      input[[id]]
    }, simplify = FALSE))
  })

   # remove words added in selectizeinput
  docs <- tm_map(docs, removeWords, c(toremovedwords())) 

    }
  })
RSesom
  • 37
  • 7
  • It's probably not related to your problem, but you might wanna check out this: http://stackoverflow.com/questions/6558921/r-boolean-operators-and – user5029763 Nov 29 '16 at 20:36
  • InputId's do not match in the IF statement. – Vance Lopez Nov 29 '16 at 23:17
  • Thanks for the link - and thanks Vance, it was just an error that I did translating (and simplifying) the code to here, but thanks for noticing! I've edited that now – RSesom Nov 30 '16 at 08:48

0 Answers0