Hello, I am new to the community and this is my first question. Please forgive me if I am doing this incorrectly. I have created an app that works when I run the app internally but gives the following error in a browser following deployment, "Error in value[3L]: input string is too long." Please see the following code below.
# global.R
library(shiny)
library(tm)
library(tidyverse)
library(wordcloud)
MASTER <- readRDS("data/dataset.clean.rds")
MASTER$DATE_RECEIVED <- as.Date(MASTER$DATE_RECEIVED, format = "%m/%d/%Y")
MASTER$FOI_TEXT <- gsub("[^[:alnum:]///' ]", "", MASTER$FOI_TEXT)
codes <- list("NIE", "EZC", "GDW", "ONU", "FTL", "MJC", "KOD", "PNO", "KNW", "DQY", "LIT", "KNT", "LJT",
"DYB", "LJS", "ITX", "KYZ", "KNX", "NNX", "FOZ", "PTD", "FPA", "IYO", "DTK", "MPB", "FMI",
"PFV", "GCY", "PIJ", "FFL", "EXS", "DWJ", "EZL", "PHU", "FTM", "DQX", "KMK", "EYJ", "GBX",
"OHR", "EZD", "PDU", "DSY", "OTP", "OOD", "FCG", "LDF")
# Creating a UI for the MAUDE Database
navbarPage("MAUDE DATABASE",
tabPanel("Search",
fluidRow(
column(4,
selectInput("code",
"Product Code:",
choices = codes,
selected = "LDF")),
column(4,
dateRangeInput("date",
label = "Date range input: yyyy-mm-dd",
startview = "month",
format = "yyyy-mm-dd",
start = Sys.Date()-365,
end = "2018-04-30")),
column(4,
downloadButton("downloaddata", "Download")),
# Show a table of the generated data
fluidRow(
column(8,
DT::dataTableOutput("table")
))
)
),
tabPanel("WordCloud",
sidebarLayout(
# Sidebar with a slider and selection inputs
sidebarPanel(
selectInput("selection", "Choose a product code",
choices = codes,
selected = "LDF"),
dateRangeInput("dates",
label = "Date range input: yyyy-mm-dd",
startview = "month",
format = "yyyy-mm-dd",
start = Sys.Date()-(2*364),
end = "2018-04-30")),
hr()
),
# Show Word Cloud
mainPanel(
plotOutput("plot",
width = "100%",
height = "600px")
)
)
)
server <- function(input, output, session) {
datasetInput <- reactive({
MASTER %>%
filter(DATE_RECEIVED >= input$date[1],
DATE_RECEIVED <= input$date[2],
DEVICE_REPORT_PRODUCT_CODE == input$code)
})
output$table <- DT::renderDataTable({
dataset <- datasetInput()
DT::datatable(dataset, filter = 'top', class = 'cell-border stripe compact hover nowrap',
options = list(
pageLength = 50,
autoWidth = TRUE,
searchHighlight = TRUE,
rownames = FALSE
))
})
output$downloaddata <- downloadHandler(
filename = function() {
paste(input$code, ".csv", sep = "")
},
content = function(file) {
readr::write_csv(datasetInput(), file)
}
)
cloudInput <- reactive({
MASTER %>%
na.omit() %>%
filter(DATE_RECEIVED >= input$dates[1],
DATE_RECEIVED <= input$dates[2],
DEVICE_REPORT_PRODUCT_CODE == input$selection)
})
# Make the wordcloud drawing predictable during a session
wordcloud_rep <- repeatable(wordcloud)
output$plot <- renderPlot({
data_set <- cloudInput()
text <- data_set$FOI_TEXT
Encoding(text) <- "UTF-8"
mycorpus <- Corpus(VectorSource(text))
mycorpus <- tm_map(mycorpus, removePunctuation)
mycorpus <- tm_map(mycorpus, content_transformer(tolower))
mycorpus <- tm_map(mycorpus, removeNumbers)
mycorpus <- tm_map(mycorpus, removeWords, stopwords("SMART"))
myDTM <- TermDocumentMatrix(mycorpus,
control = list(minWordLengths = 1))
m <- as.matrix(myDTM)
m <- sort(rowSums(m), decreasing = TRUE)
wordcloud_rep(words = names(m), freq = m, scale=c(4,0.5),
min.freq = 30, max.words = 10000, rot.per = 0,
colors = brewer.pal(8, "Dark2"), fixed.asp = FALSE)
})
}
See the following picture of the Error following the rsconnect::deployApp() function completes the deployment.
Any help with this problem is greatly appreciated. I have been stuck on this for quite some time now.
Thanks,
Matt