Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow an empty table with zero rows to create an empty gt table #283

Merged
merged 23 commits into from Jul 16, 2019

Conversation

rich-iannone
Copy link
Member

If we use table data with 0 rows but some columns defined, we get an error (and it's not informative). Here's an example:

sp500 %>% head(0) %>% gt()
Error in value[[jvseq[[jjj]]]] : subscript out of bounds 

This PR considers that zero-row table to be valid input and so a rendered table with no rows will appear. Here is the output of the above statement with the changes here:

gt_empty_table

Fixes #87.

@rich-iannone rich-iannone changed the title [WIP] Allow an empty table with zero rows to create an empty gt table Allow an empty table with zero rows to create an empty gt table Jul 16, 2019
@rich-iannone rich-iannone merged commit 1e9ef2b into master Jul 16, 2019
@rich-iannone rich-iannone deleted the empty-table branch July 16, 2019 20:45
rich-iannone added a commit that referenced this pull request Jul 17, 2019
Merge branch 'master' into cols-widths

* master:
  Allow an empty table with zero rows to create an empty gt table (#283)
  Fix for Markdown/HTML-formatting of spanner column labels (#251)
  Escaping for row group label (#252)

# Conflicts:
#	R/gt.R
rich-iannone added a commit to batpigandme/gt that referenced this pull request Nov 11, 2019
* master: (59 commits)
  add fmt_markdown to _pkgdown.yml (rstudio#371)
  Use `tidy_grepl()` instead of `expect_match()`
  Use `tidy_grepl()` & `expect_true()`
  Add `dt_*()` methods for all major, internal data structures (rstudio#355)
  Update CLA text (rstudio#373)
  remove reliance on Github version of sass, which is now updated on CRAN (rstudio#366)
  Fix for invisible top borders in rendered HTML tables (rstudio#359)
  CSS modifications (rstudio#346)
  Incorporate alpha option to `cell_fill()` (rstudio#340)
  Enable option to set row group padding in `tab_options()` (rstudio#342)
  Modify `filter()` statement (rstudio#341)
  Allow use of integers in `pct()`/`px()` (rstudio#336)
  Fix for resolving row group cells (rstudio#335)
  Easier access to footnote mark options (rstudio#333)
  Export `as.tags.gt_tbl()` (rstudio#331)
  Several `rlang`-based fixes (rstudio#334)
  Add function to specify column widths: `cols_widths()` (rstudio#293)
  Add `rstudio/sass` to Remotes list (rstudio#326)
  Fix for `cell_borders()` (rstudio#323)
  Allow an empty table with zero rows to create an empty gt table (rstudio#283)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An empty table (i.e., has >0 columns but 0 rows) should be valid input to gt()
2 participants