the code works perfectly until I select radio buttons (to filter the data by different values, be it by country/office/customer/etc..) i get this error:
Warning: Error in if: argument is of length zero
125: <reactive:officedata> [C:\Users\jzuraik\Desktop\shiny-Dashboard/server.R#247]
109: officedata
97: vbox_fun [C:\Users\jzuraik\Desktop\shiny-Dashboard/server.R#328]
96: shiny::renderUI
95: func
82: origRenderFunc
81: output$numofenqby
1: runApp
Warning: Error in if: argument is of length zero
130: <Anonymous>
Warning: Error in if: argument is of length zero
112: <Anonymous>
Warning: Error in if: argument is of length zero
130: <Anonymous>
Warning: Error in if: argument is of length zero
111: <Anonymous>
Warning: Error in if: argument is of length zero
118: <Anonymous>
Warning: Error in if: argument is of length zero
129: <Anonymous>
Warning: Error in if: argument is of length zero
101: <Anonymous>
Warning: Error in if: argument is of length zero
101: <Anonymous>
and here are the mentioned lines of code that contains this error:
officedata <- reactive({
#office country Radio Button id selescted
if(input$analysisLevel == 1)
{
subset(
ct,
ct$`Office Country` %in% input$officecountry
)
}
# office Radio Button id selescted
else if(input$analysisLevel == 2)
{
subset(
ct,
ct$Office %in% input$office
)
}
else if(input$analysisLevel == 3)
{
subset(
ct,
ct$Market %in% input$market
)
}
else if(input$analysisLevel == 4)
{
subset(
ct,
ct$`Source Market` %in% input$sourcemarket
)
}
else if(input$analysisLevel == 5)
{
subset(
ct,
ct$Customer %in% input$customer
)
}
else{
return(ct)
}
})
#filtered data
filteredcancelled <- reactive({
subset(
officedata(),
officedata()$Status %in% "Cancelled"
)
})
#Average Project Size
officedataconcom <- reactive({
subset(
officedata(),
officedata()$Start >= "2018-01-01" &
officedata()$Status == "Completed" |
officedata()$Status == "Confirmed"
)
})
#pendreq
pendreqfilter <- reactive({
subset(
officedata(),
officedata()$Start >= "2018-01-01" &
officedata()$Status %in% "Request"
)
})
#past req
pastrequestsdatefilter <- reactive({
subset(
pendreqfilter(),
pendreqfilter()$Start< Sys.Date()
)
})
##############################DATA BY OFFICE OFFICE COUNTRY MARKET SOURCE MARKET AND CUSTOMER###########################
output$numofenqby <- renderValueBox({
valueBox(nrow(officedata()), "Number of Enquiries", color = "blue", icon = icon("star"))
})
i reviewed them to try to catch what is the error, but I couldn't, and I also tried to review similar questions in stackoverflow before posting this question, but with no vain.
and a very important thing is that my code still works, even with this warning. it is just a warning, but i prefer to get rid of it.
this is the output that when i click different options it gives me the mentioned above errors:
so my console stays clean until i try to shuffle between those different buttons (Office Country/Office/Market/Source Market/Customer), and when i do, I get those Warning..
Any help please? I would be really thankful
Aucun commentaire:
Enregistrer un commentaire