Skip to content

Could the nanoplot arg missing_vals = "gap" actually return a gap, instead of a floating red circle? ⭕️ #1567

@jimgar

Description

@jimgar

Prework

  • Read and agree to the code of conduct and contributing guidelines.
  • If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
  • For any problems you identify, a minimal reproducible example so the maintainer can troubleshoot. A reproducible example is:
    • Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the tidyverse style guide.

Question

Hi, I'm really enjoying the nanoplots in the latest release. I spent several hours using them this week at work on real time series data, which contains a lot of missing values interspersed irregularly throughout.

My question is: Could missing_vals = "gap" actually return a gap, instead of the floating red circle?

For example, this table. We specify "gap" but don't get gaps, we get symbols.

Screenshot 2024-02-03 at 00 11 24

I'm sure some people would say "Ah, what you really want is to specify 'zero'". But that's not true in my case, where missing data can't be equated to zero values. Plus, I noted some minor confusion when I showed my boss a table that did use missing_vals = "zero": Because there is still a pixel or two where the bars are at zero, he made the (reasonable) interpretation that these were similar to some of the actual, but very small, data points in this dataset (e.g. 0.012).

The other option of "remove" will be useful in some contexts I'm sure, but is not appropriate in my case because I don't want the bars to get squashed together - I need to be able to compare time points down columns. I'd just like a pure gap wherever there's an NA.

If the floating red dot is unexpected behaviour I'm happy to provide sessionInfo etc. For now, here's the code for the table above.

library(tibble)
library(gt)

tibble::tibble(
  month = factor(
    c("jan", "feb", "mar", "apr", "may"),
    levels = c("jan", "feb", "mar", "apr", "may")
  ),
  `0530` = rep(NA_real_, 5L),
  `0600` = c(NA, NA, NA, 1.5, 5),
  `0630` = c(NA, 1.0999999999999943, 4.299999999999997, 8.5, NA),
  `0700` = c(
    5.099999999999994, 7.5, 11.2000000000000028, 15.599999999999994,
    0x1.2ccccccccccccp+4
  ),
  `0730` = c(
    11.2999999999999972, 14.2000000000000028, 18, NA,
    25.700000000000003
  ),
  `0800` = c(
    17.299999999999997, 20.400000000000005684, NA,
    29.700000000000003, 32.8
  ),
) |>
  gt(rowname_col = "month") |>
  cols_nanoplot(
    columns = matches("0"),
    plot_type = "bar",
    missing_vals = "gap",
    new_col_name = "saa"
  )

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions