DT icon indicating copy to clipboard operation
DT copied to clipboard

Filtering a numeric column for NA values

Open isthisthat opened this issue 2 years ago • 4 comments

Hello, here's a minimal example:

renderDT(datatable(data.frame(a=c(1,2,3,NA)), options = list(dom = 'Sflrtip', search = list(regex=TRUE)), filter = 'top'))

Is there a way to filter for the 4th row (NA) using the column filter?
Even better, can I use a regex to filter for e.g. either NA or >2?

Thank you for your help.

By filing an issue to this repo, I promise that

  • [x] I have fully read the issue guide at https://yihui.org/issue/.
  • [x] I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('DT'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/DT').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • [x] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

isthisthat avatar Apr 26 '23 15:04 isthisthat

To filter >2 you could use the SearchBuilder extension.

stla avatar Sep 06 '23 13:09 stla

Unfortunately searchbuilder does not work with server-side DT.

isthisthat avatar Sep 06 '23 21:09 isthisthat

Currently it's not possible. The only (clumsy) workaround is to add another column that has the value of is.na(), so you can use the new column to filter NA values of the original column.

yihui avatar Sep 11 '23 16:09 yihui

Maybe you can use that to display some NA and filtering them. I didn't try, I have no idea whether it works.

stla avatar Sep 11 '23 17:09 stla