-
Notifications
You must be signed in to change notification settings - Fork 26
Closed
Description
If we assign the value "" (no space) to certain cells in a data frame, gt will correctly display those as blank cells when rendering the table in RStudio, but if rendering in Quarto, those values are considered non-existent, and the remaining values are (erroneously recycled). The easy fix is to convert those values to " " (with space). I'm not sure if this is really a bug, perhaps an inconsistency; but one that could have large effects on the output. Below is a Quarto document with examples of the issue (gt version 1.0.0, quarto version 1.7.24, R version 4.5.0):
---
date: "`r Sys.Date()`"
---
```{r}
#| echo: false
#| warning: false
#| message: false
library(gt)
```
```{r}
#| echo: true
# Output is correct, but `test` is not formatted
data <- mtcars[1:5, ]
data$comment <- c("test", "`test`", "", "test", "")
data |>
gt()
```
```{r}
#| echo: true
# "" (no space) in comment treated as non-existent, so vector is (erroneously) recycled
data <- mtcars[1:5, ]
data$comment <- c("test", "`test`", "", "test", "")
data |>
gt()|>
fmt_markdown(columns = comment)
```
```{r}
#| echo: true
# " " (with space) in comment, treated as existing; works properly
data <- mtcars[1:5, ]
data$comment <- c("test", "`test`", " ", "test", " ")
data |>
gt()|>
fmt_markdown(columns = comment)
```
```{r}
#| echo: true
# Another option: NA + sub_missing (but format is different)
data <- mtcars[1:5, ]
data$comment <- c("test", "`test`", NA, "test", NA)
data |>
gt()|>
fmt_markdown(columns = comment) |>
sub_missing(columns = comment, missing_text = "")
```
Metadata
Metadata
Assignees
Labels
No labels