dewittpe / qwraps2

An updated version of qwraps with a focus on flexibility and general purpose. These functions are helpful for extracting and formatting results from R into .Rnw or .Rmd files. Additional functions for routine work such as extracting results from regression models or finding sensitivity and specificity.
http://www.peteredewitt.com/qwraps2/
GNU General Public License v3.0
36 stars 7 forks source link

Error when makup = "latex" and "\\%" in the name of a summary row #113

Open dewittpe opened 1 month ago

dewittpe commented 1 month ago

The following results in an error when passed to rmarkdown::render

---
title: "Untitled"
author: "TEST"
output:
  pdf_document: default
  bookdown::pdf_document2: null
---

```{r results = 'asis'}
library(qwraps2)
library(knitr)
library(kableExtra)

# Create som sample data
set.seed(2)
df <- data.frame(
  group = as.factor(sample(c("A","B"),8, replace = T)),
  value = sample(2:10,8, replace=F),
  pos = as.factor(sample(c("pos.","neg."),8, replace = T))
)

# Define the table for summary_table
summary <- list(
  "Groups" = list(
    "Value" = ~ median_iqr(value),
    "Pos. (\\%)" = ~ qwraps2::n_perc(pos == "pos."))
)

new_table <- summary_table(df, summaries = summary, by = "group",
                           qable_args = list()
)

new_table

image

I suspect this is problem with regex.

Issue found on this stackoverflow post

dewittpe commented 2 weeks ago

This bug could (should) be fixed by addressing the refactor noted in #114