Mathjax rendering:
library(xtable)
shiny::runApp(
list(
ui = pageWithSidebar(
headerPanel("TEST"),
sidebarPanel(
helpText('Is this matrix cool ?')
),
mainPanel(
uiOutput('matrix')
)
)
,
server = function(input,output){
output$matrix <- renderUI({
M <- matrix(rep(1,6),nrow=3)
rownames(M) <- c('a','b','c')
M <- print(xtable(M, align=rep("c", ncol(M)+1)),
floating=FALSE, tabular.environment="array", comment=FALSE, print.results=FALSE)
html <- paste0("$$", M, "$$")
list(
tags$script(src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML', type = 'text/javascript'),
HTML(html)
)
})
}
)
)
Update July 2015
Something has changed and the MathJax rendering does not work anymore. Maybe this is the link to the MathJax library, I don't know. Anyway, there's a new function in Shiny, withMathJax
, which does the job. Replace the server
function by the following one:
server = function(input,output){
output$matrix <- renderUI({
M <- matrix(rep(1,6),nrow=3)
rownames(M) <- c('a','b','c')
M <- print(xtable(M, align=rep("c", ncol(M)+1)),
floating=FALSE, tabular.environment="array", comment=FALSE, print.results=FALSE)
html <- paste0("$$", M, "$$")
list(
withMathJax(HTML(html))
)
})
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…