I am using R Markdown to create a dashboard, as it is easier for me than using R-Shiny. I have a piece of code that stopped working after I upgraded tidyverse. Tidyverse has changed the behavior of its str_detect() string manipulation in that it now throws an error if an empty string is detected. So, I need some suggestions. Below is the code and what I need to do (focus on the str_detect() part).
df %>%
select(YEAR,
Q...) %>%
filter(
!is.na(HAILWT) &
CODMSIZE >= input$codmeshTBL[1] & CODMSIZE <= input$codmeshTBL[2] &
YEAR >=
... &
str_detect(CATDISP, if_else(input$dispositionTBL == "All", "", input$dispositionTBL))
... &
) %>%
...
The input$dispositionTBL is a dropdown control with options "All", "Discarded", "Kept", and "Unknown" as options. The "discarded", "kept", and "unknown" are rows of the CATDISP column in the dataframe. The "All" I added to the control. When the user selects "All", there should be no filtering on the column 'CATDISP'. When the user selects anything else, filtering should occur on the selected option. This all worked fine before the update, but now throws the error "str_detect()
:! pattern
can't be the empty string (""
).". This is b/c of the empty string from the 'All' selection. So, I tried to add NULL, True, and c("Discarded", "Kept", "Unknown") to no avail. Anyone out there has a strategy/suggestion on how I can disable filtering upon the user selecting 'All' for that particular column? Thx a lot.