Greetings all,
I need help for an issue in shinyapps.io with else if statement.
This is my code :
req51<- data.frame(req5)
t<- nrow(req51)
x <- data.frame(classe=1:t, id=rep(1, t))
for (i in 1:t) {
if (req51[i,"Age"]<30) {x[i, "classe"] = "20-30"}
else if (req51[i,"Age"]<40) {x[i, "classe"] = "30-40"}
else if (req51[i,"Age"]<50) {x[i, "classe"] = "40-50"}
else {x[i, "classe"] = "50-60"}
}
When i run this locally it works well, but when i deploy the app on shinyapps.io i get the following error :
Warning: Error in if: missing value where TRUE/FALSE needed.
I dont really know what is going wrong.
Can somebody help please?
Thanks.
Sassire
...
We don't really have enough info to help you out. Could you post the content of your logs and ask this with a minimal REPR oducible EX ample (reprex) ? A reprex makes it much easier for others to understand your issue and figure out how to help.
Please have a look at this guide, to see how to create one for a shiny app
Shiny issues can be challenging to resolve relative to other problems with your code or statistical methods. Shiny apps are often large, complex projects with interacting files.
When seeking help from others it is considered polite to:
First, do your best to work through RStudio's debugging tools to diagnose your issue on your own. Often those shiny logs and tracebacks are useful to others trying to help out.
Second, strive to minimize the effort required to replicate your issue. You can do this with a reproducible example ("reprex").
Shiny Debugging
Errors in Shiny code can be difficult to track down. If you don't know where your problem is coming from, you can track it down with some o…
Dear @andresrcs thank you for your reaction. I finally understood the issue. It comes from the use of IF statement inside the FOR loop. I was able to solve it by using the "IFELSE" statement instead. Thanks.
mara
June 7, 2019, 12:01pm
4
If your question's been answered (even if by you), would you mind choosing a solution? (See FAQ below for how).
Having questions checked as resolved makes it a bit easier to navigate the site visually and see which threads still need help.
If your question has been answered, don't forget to mark the solution!
How do I mark a solution?
Find the reply you want to mark as the solution and look for the row of small gray icons at the bottom of that reply. Click the one that looks like a box with a checkmark in it:
[image]
Hovering over the mark solution button shows the label, "Select if this reply solves the problem". If you don't see the mark solution button, try clicking the three dots button ( ••• ) to expand the full set of options.
When a solution is chosen, the icon turns green and the hover label changes to: "Unselect if this reply no longer solves the problem". Success!
[solution_reply_author]
…
Thanks
system
Closed
July 31, 2019, 4:01pm
5
This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.