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

Bug Report: Error with Word output when mixing a blank cell in insert_row() with set_markdown() #219

Closed
ddsjoberg opened this issue Jan 14, 2022 · 3 comments

Comments

@ddsjoberg
Copy link

Hey hey!

A user of gtsummary encountered an error when they specified a blank column header with Word output.

The header row is added with with insert_row(), and that is followed by set_markdown() and the error occurs in set_markdown().

Here's an example, thanks!

---
output: word_document
---

```{r}
library(gtsummary)
tbla <- 
  trial %>%
  select(trt) %>%
  tbl_summary()
```

```{r}
tbla$table_body %>%
  dplyr::select(label, stat_0) %>%
  huxtable::as_huxtable(add_colnames = FALSE) %>%
  huxtable::insert_row(after = 0, label = "", stat_0 = "**N = 200**") %>%
  huxtable::set_markdown(
    row = 1L, col = huxtable::everywhere,
    value = TRUE
  )
```

This is the error:

Quitting from lines 15-23 (reprex_huxtable.Rmd) 
Error in rep(list(flatten_branch), n) : invalid 'times' argument
Calls: <Anonymous> ... lapply -> flatten_ast -> <Anonymous> -> map -> list2
Execution halted
@hughjonesd
Copy link
Owner

OK, this comes if you call ftExtra::as_paragraph_md(cell, .from = "commonmark+strikeout") with an empty cell. Seems like a bug in ftExtra, I'll head over there.

@hughjonesd
Copy link
Owner

The workaround for now would be to replace the last line with:

 huxtable::set_markdown(
    row = 1L, col = 2L,
    value = TRUE
  )

or more generally, only use set_markdown on non-empty cells.

@hughjonesd
Copy link
Owner

Fixed in ftExtra.

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

No branches or pull requests

2 participants