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()))
}
})