Latex, RenderTable in Shiny, R

本秂侑毒 提交于 2019-12-07 21:26:41

问题


I just trying to get $\10^{-1}$ in a table in Shiny, but it is not working. I'm trying the following code (thanks in advance):

ui.R:

require(shiny)  
shinyUI(tableOutput('mytable') 
)

server.R:

  require(shiny)  
shinyServer(function(input, output){  
output$mytable <- renderTable({  
df <- data.frame(A = c("$\\10^{-1}$", 33.1, 6),B = c(111111, 3333333, 3123.233))  
df  
  }, sanitize.text.function = function(x) x)
})

回答1:


You can use mathJAX in shiny:

require(shiny)  
ui <- shinyUI(
  fluidPage(
    withMathJax()
    , h2("$$\\mbox{My Math example }\\sqrt{2}$$")
    , tableOutput('mytable')
    )
)
server <- function(input, output, session){  
  output$mytable <- renderTable({  
    df <- data.frame(A = c(HTML("$$\\alpha+\\beta$$"), 33.1, 6),B = c(111111, 3333333, 3123.233))  
    df  
  }, sanitize.text.function = function(x) x)
}

shinyApp(ui = ui, server = server)



来源:https://stackoverflow.com/questions/26620221/latex-rendertable-in-shiny-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!