Fiesto
Fiesto

Reputation: 17

Interpret markdown tags when using kableExtra::collapse_rows

I am creating a PDF document using R Markdown. I would like to format some texts within a cell, and also have the possibility of collapsing equal cells within the same row.

I am using the following code for a table in an R Markdown file in RStudio:

library(knitr)
library(kableExtra)

data1 <- kable(data.frame(
c("noun", "noun", "adjective", "verb"),
c("cat", "cat", "good", "bad"),
c("other information", "more information", "another text", "*This should be in italics*, this not...")
), col.names = c("Type", "Example", "Just Text"))
collapse_rows(data1)
data1

This produces this:

The table on the top collapses the cells with the same contents within the same row, but it does not interpret the Markdown tag for italics (i.e. *).

The table on the bottom interprets the italics correctly, because it is not using collapse_rows().

Any help is appreciated, even if it means using other packages or alternatives to collapse rows and display formatting for a Latex/PDF output.

Upvotes: 0

Views: 17

Answers (0)

Related Questions