glin / reactable

Interactive data tables for R
https://glin.github.io/reactable
Other
612 stars 79 forks source link

Change request: default symbol when the value is absent #380

Open vladimirvakhlov opened 2 days ago

vladimirvakhlov commented 2 days ago

User story: It would be nice to have a setting that allows to represent a custom symbol when the value is absent.

Use case: User is comparing values by two parameters, and not all parameters may exist for all the values. In such a case, the cells will be just empty.

If a user want to put, let's say, the em-dash, then he can apply custom cell function to substitute the empty value with em-dash ad hoc, for example:

        cell = function(value) {
          if (is.na(value) || value == "") {
            value <- "—"
          } else {
            value
          }          
        },
      )

but in this case colFormat, like

format = colFormat(separators = TRUE, locales = "en-NZ") stops working for the column, and you have to create more workaround for the values processing inside custom cell function, for our example:

value <- format(value, big.mark = ",", decimal.mark = ".", scientific = FALSE)

or, for example, for percentages:

value <- sprintf("%.1f%%", value * 100)

in which moment the values stop become a number and become the text, which will be sorted in a different way.

illustration picture of the types of the data where it may be useful. image

Not a priority issue, but may ease the life.