I am facing an issue with my shiny app, where columnar data rendered from a csv file is displayed in rows instead of columns (Each variable except the header is being treated as a column, whereas it should be aligned in row). Every time I access the shiny page it pops up the following Error: "DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter '10' for row 10. For more information about this error, please see 4. Warning: Requested unknown parameter". Please see the attached image below
The same application with exact same code is running absolutely fine in the quality cluster and fails in the production. Both landscapes are exactly the same. Please see the two image below of how the data should look and how it currently is being displayed.
I have removed the sections of code not associated with the issue. Also, the specific issue I am encountering is only on the status tab of the shiny application. Not sure if it helps, but if I manually change all the values of the input variables to integer I do not get this error, whereas even if one of the input variables contains a character the "status" tab throws the data table error and each character of a single input value is treated as separate column input.
The application is running in on RHEL 7 with R 3.6
Please find the attached code for server.R and UI.R
Server.R
Server.R
shinyServer(function(session,input, output) {
myAnalysisList = reactiveFileReader(1000, NULL, "scheduledAnalyses.csv", readFunc = read.csv, stringsAsFactors = FALSE, encoding = "UTF-8")
observeEvent(input$schedule,{
tryCatch({
adjustedDateRange<-getAdjustedDateRange(input$dateRange[1],input$dateRange[2],type = input$forecastType)
currTime = Sys.time()
print(input$forecastHorizon)
forecastHorizonCorrected = input$forecastHorizon
if(input$forecastType!="Monthly"){
forecastHorizonCorrected = input$forecastHorizonWeekly
}
newRow = data.frame(ScheduledAt = as.character(currTime),
StartDate = as.character(adjustedDateRange$startDate),
EndDate = as.character(adjustedDateRange$endDate),
Linea = input$productLinea,
Series = input$productSeries,
Group = input$productGroup,
StatGroup = input$productStatGroup,
ProductCode = input$productCode,
DemProfile = input$demandProfileSelected,
FType = input$forecastType,
FHorizon = forecastHorizonCorrected,
Status = "Scheduled",
Duration = 0)
msg="Just before writing the Schedule"
write.table(newRow,"scheduledAnalyses.csv",sep = "," ,row.names = FALSE,append = TRUE,col.names = FALSE)
output$scheduleStatus = renderUI({
box(title = "Status : Success",status = "success",width =NULL,solidHeader = TRUE,paste("Process has been scheduled at ",currTime, " ",format(currTime, format = "%Z")))
})
}, error = function(errorMsg){
output$scheduleStatus = renderUI({
box(title = "Status : Error",status = "danger", solidHeader = TRUE ,paste("Unable to schedule the process!\n Error: ",errorMsg$message,msg))
})
})
#myAnalysisList <<- bind_rows(myAnalysisList,newRow)
output$analysesList <- renderDataTable(myAnalysisList())
})
output$analysesList = renderDataTable(myAnalysisList())
# observeEvent(input$forecastHorizon,{
# print(input$forecastHorizon)
# })
UI.R
inp<-read.csv("inp.csv",stringsAsFactors = FALSE)
#-------------------------Loading data from Spark ---------------------------------#
#tbl_cache(sc,"demand_forecast_newcode_monthyr")
#inpPtr<-tbl(sc,"demand_forecast_newcode_duedate") %>% filter(linea == "Linea Differenziali DS271" | linea == "Linea Differenziali Elettronici DSE201" | linea == "Linea Differenziali Puri F200" )
#inp<-collect(inpPtr)
#columnNames<-colnames(inp)
#newNames<-sub("^.*\\.","",columnNames)
#colnames(inp)<-newNames
#View(inp)
inp<- inp[!is.na(inp$due_date), ]
inp<- inp[!is.na(inp$linea), ]
inp<- inp[!is.na(inp$series), ]
inp<- inp[!is.na(inp$groupo), ]
inp<- inp[!is.na(inp$gruppo_stat), ]
inp<- inp[!is.na(inp$productcode), ]
inp$due_date <- as.Date(inp$due_date, origin = "1970-01-01")
inpmod <- inp %>%
mutate(Year = year(due_date),
Month = month(due_date),
MonthlyDate = format(due_date, format= "%Y-%m-01"),
QuarterlyDate = quarter(due_date,with_year = TRUE),
SemesterDate = semester(due_date,with_year = TRUE),
WeekInYear = isoweek(due_date)
)
lineaChoices = c("All",unique(inpmod$linea))
serieChoices = c("All",unique(inpmod$series))
groupChoices = c("All",unique(inpmod$groupo))
statGroupChoices = c("All",unique(inpmod$gruppo_stat))
productCodeChoices = c("All",unique(inpmod$materiale))
# Define UI for application that plots random distributions
shinyUI(dashboardPage(
skin="red",
dashboardHeader(title = "Demand Forecasting, ABB Inc.", titleWidth = 350),
dashboardSidebar(
sidebarMenu(
menuItem( "Forecast", tabName = "forecastTab", icon = icon("line-chart")),
menuItem( "Status", tabName = "statusTab", icon = icon("cogs"))
)
),
dashboardBody(
tabItems(
tabItem( tabName = "forecastTab",
fluidRow(
column( width = 8,
fluidRow(
column( width = 12,
box(title = "Timeline", status = "danger", width = NULL,
dateRangeInput("dateRange","Date Range(MM-YYYY):", format = "MM-yyyy",
startview = "decade", start = "2010-01-01",end = Sys.Date())
#tags$br(),
#textOutput("AdjustedDate")
)
)
),
fluidRow(
column( width =12,
box(title = "Product Hierarchy", status = "danger", width = NULL,
column(width = 6,
selectInput("productLinea","Linea", selectize = TRUE,
choices = lineaChoices, selected = "All"),
tags$br(),
selectInput("productGroup","Group",selectize = TRUE,
choices = statGroupChoices, selected = "All"),
tags$br(),
selectInput("productCode","Product Code",selectize = TRUE,
choices =productCodeChoices, selected = "All")
),
column(width = 6,
selectInput("productSeries","Series",selectize = TRUE,
choices = serieChoices, selected = "All"),
tags$br(),
selectInput("productStatGroup","Statistical Group", selectize = TRUE,
choices = groupChoices, selected = "All")
)
)
)
)
),
column( width = 4,
box( title = "Forecast Parameters", status = "danger", width = NULL,
tags$br(),
selectInput("demandProfileSelected","Demand Profile",
choices = c("Predictable", "Unstable", "All"), selected = "Predictable"),
#tags$h4("Select the required granularity for the forecast"),
tags$br(),
selectInput("forecastType","Forecast Type", choices = c("Monthly","Weekly"),
selected = "Monthly"),
tags$hr(),
tags$br(),
#tags$h4("Select the number of time periods from end date to forecast"),
#tags$br(),
conditionalPanel("input.forecastType=='Monthly'",
sliderInput("forecastHorizon", "Forecast Horizon:", 1, 12, 6)),
conditionalPanel("input.forecastType=='Weekly'",
sliderInput("forecastHorizonWeekly", "Forecast Horizon:", 1, 52, 12))
)
)
),
fluidRow(
column(width = 2,
actionButton("clear"," Clear", class = "btn-lg btn-success",
style='color: white; width:100%; height:70px; font-size:150%;',
icon = icon("refresh"))
),
column(width = 3,
actionButton("schedule"," Schedule & Start", class = "btn-lg",
style='color: white; background-color: #dd4b39; width:100%; height:70px; font-size:150%;',
icon = icon("cogs"))
)
# column(width = 8,
# uiOutput("scheduleStatus")
# )
),
fluidRow(
tags$br(),
column(width = 3),
column( width = 6,
uiOutput("scheduleStatus")
)
)
),
tabItem(tabName = "statusTab",
#p("COmiNg sOoN")
fluidRow(
column(12,
box(title = "Scheduled Forecasts", status = "danger", width = NULL,
dataTableOutput('analysesList')
)
)
)
)
)
)
))