Filtering in null or empty values in tables

Hi! I found Shiny + DT allowing regex in filters a handy and minimalistic toolset to browse data tables easily.

Only one problem: I'm not able to find a regex to filter out null or empty values.

Please, could you help me? Thanks!

Hi. Without a concrete example, I can only guess at what your exact purpose is. But here's a possible (?) solution:

For filtering out blanks:

df <- subset(df, df$column_name == "")

For filtering out NA values

df <- subset(df,$column_name))
1 Like

Hi! Thanks for making the guess, and sorry for not being clearer in the original post. In fact, I think the title is wrong: it should read "filtering in"!

The point is that I want null and/or empty values included in the rendered table, and to be able to filter them in on the fly. Please, see below (those are public data available at our website, no issue about privacy):

I can easily use regex to select records containing or not containing a string in any variable. Even by using ^ I can filter out all records having null or empty values in any variable:

I get this by simply enabling regex in search list, as in:

    output$row0202col0101 <- renderDT(
    teamDiff_full, # data
    class = "display nowrap compact", # style
    filter = "top", # location of column filters
    rownames= FALSE,
    options = list(search = list(regex = TRUE, caseInsensitive = FALSE), pageLength = 10)

But, how could I get only the records with, for instance, no value for SA_RP?

Thank you very much!

A very simple approach that I didn't realize before: to replace NA and nulls with a string, I used "null" and filter for that string.

To replace across multiple columns, I followed Apply a function (or functions) across multiple columns — across • dplyr and wrote:

data.frame %>% mutate(across(everything(), .fns = ~replace_na(.,"_null_")))

As in r - Convert NA to 0 in columns selected by name using dplyr mutate across - Stack Overflow


This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.