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.
<code>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)
</code>
<code>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)
</code>
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)