library(shiny)
library(wordcloud)
library(tm)
shinyServer(function(input, output) {
datainput <- reactive({
words <- Corpus(DirSource("temp/"))
words <- tm_map(words, stripWhitespace)
words <- tm_map(words, content_transformer(tolower))
words <- tm_map(words, removeWords, stopwords("english"))
})
finalinput <- reactive({
if (input$checkbox1) datainput <- tm_map(datainput(), removeNumbers)
if (input$checkbox2) datainput <- tm_map(datainput(), removePunctuation)
if (input$checkbox3) datainput <- tm_map(datainput(), stemDocument)
})
make_cloud <- reactive({
wordcloud(finalinput(),
scale=c(5, 0.5),
min.freq=3,
max.words=input$slider,
random.order=input$checkbox4,
rot.per=0.35,
use.r.layout=FALSE,
colors=brewer.pal(8, "Dark2"))
})
output$wordcloud_img <- downloadHandler(
filename = "wordcloud.png",
content = function(cloud) {
png(cloud)
make_cloud()
dev.off()
})
output$wordcloud <- renderPlot({
make_cloud()
})
})
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/CANROs4epNZy6VLVhj%2B2bcQS5x0eze96va%2BXPienrHtOS%2BZKtXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.