Skip to content

explicit groups seem to be required for cells_summary when summarizing a full table (i.e. a single group) #581

Description

@kendonB

I found that I couldn't select summary rows through cells_summary when following the example here: https://gt.rstudio.com/reference/cells_summary.html

It seems that the minimal change required to make it fail is to remove the groups in that example. In this example and my real-life one, there is only a single group so it shouldn't matter.

library(tidyverse)
library(gt)
countrypops %>%
  dplyr::filter(
    country_name == "Japan",
    year < 1970) %>%
  dplyr::select(-contains("country")) %>%
  dplyr::mutate(
    decade = paste0(substr(year, 1, 3), "0s")
  ) %>%
  gt(
    rowname_col = "year"
  ) %>%
  summary_rows(
    columns = vars(population),
    fns = list("min", "max"),
    formatter = fmt_number,
    decimals = 0
  ) %>%
  tab_style(
    style = list(
      cell_text(style = "italic"),
      cell_fill(color = "lightblue")
    ),
    locations = cells_summary(
      columns = vars(population),
      rows = 1)
  )
#> Error: All column or row indices given must be present in `data_tbl`.

Created on 2020-05-11 by the reprex package (v0.3.0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions