I am trying to create a table using DT and I want to create a container that shows data as shown below.
However, the closest I have got to is from the code below.
library(data.table)
library(DT)
#a custom table container
sketch = htmltools::withTags(table(
class = 'display',
thead(
tr(
th(colspan = 3, 'First'),
th(colspan = 8, 'Criteria')
),
tr(
th(colspan = 3, 'Name1'),
th(colspan = 1, 'Car'),
th(colspan = 3, 'Criteria'),
th(colspan = 2, 'Criteria2'),
th(colspan = 3, 'Criteria3')
),
tr(
lapply(c('vs', 'gear', 'carb', 'Car', 'mpg', 'cyl', 'disp', 'hp', 'drat', 'wt', 'qsec', 'am'), th)
)
)
))
mtcars$Car = row.names(mtcars)
header_trial = mtcars
header_trial = data.table(header_trial)
setkey(header_trial, vs, gear, carb)
setcolorder(header_trial, c('vs', 'gear', 'carb', 'Car', 'mpg', 'cyl', 'disp', 'hp', 'drat', 'wt', 'qsec', 'am'))
datatable(header_trial, container = sketch, rownames = FALSE, class = "cell-border stripe")
Can you help me configuring the rows of the table as well in container in order to display like the example in the picture?
Thanks!