如何格式化 tableHTML 包中的 colnames 文本?

How to format colnames text in tableHTML package?

HTML 在行名、标题和页脚中工作正常。与 colnames 中的直觉相反,它不起作用。我怎样才能在 colnames 中实现等效格式?

mx <- matrix(1:9, nrow = 3, 
             dimnames = list(c("<i>&alpha;<sub>i</sub></i>", 
                               "<i>&beta;<sub>i</sub></i>", 
                               "<i>&gamma;<sub>i</sub></i>"),
                             c("<i>&Phi;<sub>i</sub></i>", 
                               "<i>&Sigma;<sub>i</sub></i>", 
                               "<i>&Tau;<sub>i</sub></i>")))
library(tableHTML)
tableHTML(mx
          , widths = rep(20, 4)
          , border = 0
          , rownames = TRUE
          , caption = "<b>Table 1: <i>&Phi;<sub>i</sub></i> and their <i>&Sigma;<sub>i</sub></i> and <i>&Tau;<sub>i</sub></i></b>"
          , footer = "<i>Note: </i><i>&Phi;<sub>i</sub></i>. Do re mi fa so la."
          , collapse = "separate"
          , spacing = "5px"
          , theme = 'scientific'
)

默认情况下,

tableHTML 将转义 ><(如果数据中包含 HTML 标记,则它们会在它们不应打开和关闭的位置打开和关闭)。因此,您可以使用 escape 参数关闭转义:

library(tableHTML)
tableHTML(mx
          , widths = rep(50, 4)
          , border = 0
          , rownames = TRUE
          , caption = "<b>Table 1: <i>&Phi;<sub>i</sub></i> and their <i>&Sigma;<sub>i</sub></i> and <i>&Tau;<sub>i</sub></i></b>"
          , footer = "<i>Note: </i><i>&Phi;<sub>i</sub></i>. Do re mi fa so la."
          , collapse = "separate"
          , spacing = "5px"
          , escape = FALSE
          , theme = 'scientific'
)