R DataTable Library: how to create a table with RowSpan

Viewed 28

I hope to create a datatable looking like the image, where some row headers span across multiple rows. One example for complex columns header are provided in this document, but I am unsure how to create a datatable with Rowspans. Does any one know how to do it?

The following is my attempt to create the table

numPeople = 6

sketch = htmltools::withTags(table(
      class = 'display',
      thead(
        tr(
          lapply(paste0(rep("Person", numPeople), c(1:numPeople)), th)
          ),
        tr(
          th(rowspan = 2, "fav"),
          th("color")
        ),
        tr(th("Fl")),
        tr(
          th(rowspan = 2, "least fav"),
          th("color")
        ),
        tr(th(
          "Flavor"
        ))
        )
    ))

enter image description here

0 Answers
Related