2

HTML is working fine in the rownames as well as in the caption and in the footer. Contrary to intuition in the colnames it's not working. How could I achieve equivalent formatting within the 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'
)

enter image description here

LyzandeR
  • 37,047
  • 12
  • 77
  • 87
jay.sf
  • 60,139
  • 8
  • 53
  • 110

1 Answers1

2

tableHTML will escape > and < by default (HTML tags open and close where they shouldn't if they are contained within the data). So, you can just turn escaping off using the escape argument:

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'
)

enter image description here

LyzandeR
  • 37,047
  • 12
  • 77
  • 87
  • Works like a charm, thanks! BTW your package is really great, I love working with it; thank you very much for your work on this! – jay.sf Nov 24 '17 at 11:16
  • 1
    Thank you very much for your kind words @jaySf. Glad that you like it :) – LyzandeR Nov 24 '17 at 11:18