Quantcast
Channel: Active questions tagged kable - Stack Overflow
Viewing all articles
Browse latest Browse all 105

kableExtra html table: pack_rows() ignores  

$
0
0

I am rendering an html document in Quarto (engine: knitr). I have added some trailing whitespaces in a kableExtra table using " ". However, as soon as I add pack_rows() to the mix, " " is rendered as text in the table. Any idea why this is happening and how I can fix it? Using escape = FALSE within kable() does not help.

This works as intended:

library(tidyverse)library(kableExtra)set.seed(404)mtcars_tbl <-   mtcars %>%   mutate(    p = round(runif(nrow(.), 0, .1), 2),    p = case_when(      p < .05 ~ paste0(p, "*"),      TRUE ~ paste0(p, "&nbsp;&nbsp;")    )  ) %>%  select(mpg, hp, p)mtcars_tbl %>%   head() %>%   kable(align = "lrrr")

kableExtra table with trailing whitespaces correctly rendered in the last column.

This does not:

mtcars_tbl %>%   head() %>%   kable(align = "lrrr") %>%   pack_rows(index = c("group 1" = 3, "group 2" = 3))

kableExtra table where pack_rows() prevents trailing whitespace from being rendered in the last column.

Thanks in advance for any tips!


Viewing all articles
Browse latest Browse all 105

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>