Skip to content

Add documentation to clarify when na_color is used in data_color() #1304

@pa-nathaniel

Description

@pa-nathaniel

Description

In #1301, @rich-iannone and I realized that the documentation for the na_color argument in gt::data_color() could be improved to clarify that it is ignored when the user specifies an argument to fn.

A suggested update is to add something to the documentation like:

@param na_color [...] ignored if the user specifies the value of `fn`, in which case the argument to `fn` should specify the color of NA arguments

Reproducible example

The code below is what I tried that I expected would work, but didn't.

library(gt)
sza |>
       dplyr::filter(latitude == 20 & tst <= "1200") |>
       dplyr::select(-latitude) |>
       dplyr::filter(!is.na(sza)) |>
       tidyr::spread(key = "tst", value = sza) |>
       gt(rowname_col = "month") |>
       data_color(
             fn = scales::col_numeric(
                   palette = c("red", "white", "green"),
                   domain = c(0, 50, 100)
               ), 
             na_color = "white"   # <- Color NA cells to be white (does not seem to do anything)
         )

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions