0

I recently updated my R and Rstudio, and now kable doesn't seem to recognizing styling from qwraps2. Here's a reproducible example with the output I get in Viewer.

options(qwraps2_markup = "markdown")
summary_statistics <-
  list(
    "Sepal Length" =
      list(
        "N (%)" = ~qwraps2::n_perc0(!is.na(Sepal.Length), na_rm = TRUE),
        "Mean (SD)" = ~paste0(round(mean(Sepal.Length, na.rm = T), 1), ' (', 
                              round(sd(Sepal.Length, na.rm = T), 1), ')')
      ),
    "Sepal Width" =
      list(
        "N (%)" = ~qwraps2::n_perc0(!is.na(Sepal.Width), na_rm = TRUE),
        "Mean (SD)" = ~paste0(round(mean(Sepal.Width, na.rm = T), 1), ' (', 
                              round(sd(Sepal.Width, na.rm = T), 1), ')')
      )
  )

tbl <- summary_table(iris, summary_statistics, by = 'Species')
colnames(tbl) <- gsub('\\(', '\\<br\\/\\>\\(', colnames(tbl))

kable(tbl, col.names = colnames(tbl), escape = F) %>%
  kable_styling() %>%
  pack_rows('Sepal Length', 1, 2) %>%
  pack_rows('Sepal Width', 3, 4)

enter image description here

UPDATE: Styling issue is fixed by using kbl(). However, is there an option so that the header row for each section is not repeated from summary_statistics and pack_rows? Would like to keep the header rows from pack_rows instead.

enter image description here

3
  • Use kbl(), not kable(). Commented May 31, 2024 at 22:09
  • Thanks, that worked! Is there an option so that the header row for each section is not repeated from summary_statistics and pack_rows? Would like to keep the header rows from pack_rows instead. Commented May 31, 2024 at 22:55
  • 1
    This problem is a result of qwraps2 trying to format the text and having kableExtra then trying for format the formatted text. This is known issue and will be addressed in a future release of qwraps2 Commented Sep 5, 2024 at 15:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.