HTML在rownames以及标题和页脚中工作正常。与姓氏中的直觉相反,它不起作用。我怎样才能在colnames中实现等效的格式化?
mx <- matrix(1:9, nrow = 3,
dimnames = list(c("<i>α<sub>i</sub></i>",
"<i>β<sub>i</sub></i>",
"<i>γ<sub>i</sub></i>"),
c("<i>Φ<sub>i</sub></i>",
"<i>Σ<sub>i</sub></i>",
"<i>Τ<sub>i</sub></i>")))
library(tableHTML)
tableHTML(mx
, widths = rep(20, 4)
, border = 0
, rownames = TRUE
, caption = "<b>Table 1: <i>Φ<sub>i</sub></i> and their <i>Σ<sub>i</sub></i> and <i>Τ<sub>i</sub></i></b>"
, footer = "<i>Note: </i><i>Φ<sub>i</sub></i>. Do re mi fa so la."
, collapse = "separate"
, spacing = "5px"
, theme = 'scientific'
)
答案 0 :(得分:2)
tableHTML
默认会转义>
和<
(如果HTML数据包含在数据中,则不会打开和关闭HTML标签)。因此,您可以使用escape
参数转义转义:
library(tableHTML)
tableHTML(mx
, widths = rep(50, 4)
, border = 0
, rownames = TRUE
, caption = "<b>Table 1: <i>Φ<sub>i</sub></i> and their <i>Σ<sub>i</sub></i> and <i>Τ<sub>i</sub></i></b>"
, footer = "<i>Note: </i><i>Φ<sub>i</sub></i>. Do re mi fa so la."
, collapse = "separate"
, spacing = "5px"
, escape = FALSE
, theme = 'scientific'
)