Skip to content

Coloring NA values #1349

@kwakuduahc1

Description

@kwakuduahc1

I have been trying to color only NA values without coloring other variables with the data_color function but without success.

There appears to be an inconsistency in the behavior of the row parameter:

library(tidyverse)
library(gt)

dset <- tibble(
               temperature = c(1, 2, NA),
               pulse = c(NA, 1, 1.2)
        )

This does not work

dset %>%
  gt() %>%
  data_color(rows = is.na(everything()))
Error in `get_contrast_ratio()`:
! At least one color defined for each of `color_1` and `color_2`.~

... but this does

dset %>%
  gt() %>%
  data_color(rows = is.numeric(everything()))

is.na and is.numeric in my knowledge evaluates to the same logical value(s)

dset %>%
  gt() %>%
  data_color(rows = where( ~ is.na(.)))

I want to color only the NA values without coloring any other value

image

Thanks.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions