I have a shinny app and with a numeric input and I initiate its value in the UI like empty, I am trying to evaluate if this value is not empty then do something but it not working
this is how I initiate on the UI
numericInput("Max_Risk", label="Max Risk", value="")
when a button is pressed
I assign its value to a variable
max_risk = input$Max_Risk
then I have an if condition that evaluates the value of max_risk
if (max_risk != ""){
dat2 <- dplyr::filter(dat2, coe_var < max_risk)
}
when there is a value on the input, lets say the number 86, it does work and gets into the of statement and continues with the code, but when there is no value in the input, i.e is left blank I get this error
Warning: Error in if: missing value where TRUE/FALSE needed
I need that if the input is left blank then don't do the if statement and continue with the code, any help thanks
Juan
Maybe it is NA value at the begining. Try:
if (!is.na(max_risk) && max_risk != ""){
dat2 <- dplyr::filter(dat2, coe_var < max_risk)
}
Warning: Error in if: missing value where TRUE/FALSE needed usually means that you are trying to evaluate a variable which is a NA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With