如何格式化 tableHTML 包中的 colnames 文本?
How to format colnames text in tableHTML package?
HTML 在行名、标题和页脚中工作正常。与 colnames 中的直觉相反,它不起作用。我怎样才能在 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'
)
默认情况下,tableHTML
将转义 >
和 <
(如果数据中包含 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'
)
HTML 在行名、标题和页脚中工作正常。与 colnames 中的直觉相反,它不起作用。我怎样才能在 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'
)
tableHTML
将转义 >
和 <
(如果数据中包含 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'
)