2014-10-28 105 views
1

我只是试图在Shiny中的表中获得$\10^{-1}$,但它不起作用。我想下面的代码(在此先感谢):Latex,RenderTable in Shiny,R

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

您可以使用mathJAX闪亮:

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) 

enter image description here

+0

谢谢jdharrison!我刚刚意识到我正在使用R-studio浏览器,并导致问题! – user150272 2014-10-29 02:19:25

+0

@ user150272如果这回答你的问题,请考虑通过打勾来回答问题。 – jdharrison 2014-10-29 02:30:01