我无法弄清楚如何创建包含类似数学表达式的LaTeX的输出表。
如何在我的示例中显示希腊字母rho?
library(shiny)
ui <- fluidPage(
tableOutput("table")
)
server <- function(input, output) {
output$table <- renderTable({
ts_summary <- data.frame(rho_1 = 1,
rho_2 = 2,
rho_3 = 3,
rho_4 = 4,
rho_5 = 5)
ts_summary
})
}
shinyApp(ui = ui, server = server)
答案 0 :(得分:2)
你是对的。这很棘手,因为关于如何为数据框命名列的惯例。这是一个可能的解决方案:
编辑:解决方案仅适用于静态表。
更新:
可以在此处找到帮助:https://github.com/rstudio/DT/issues/168
所以afaik,它只适用于DT :: ....
library(shiny)
library(DT)
ui <- fluidPage(
withMathJax(),
selectInput("number", "Number:", 1:4),
DT::dataTableOutput('table')
)
server <- function(input, output) {
proxy = dataTableProxy('table')
observe({
replaceData(proxy, df(), rownames = FALSE)
})
df <- reactive({
df = data.frame(index = 1)
df['$$\\rho_1$$'] <- input$number[1]
df['$$\\rho_2$$'] <- 2
df['$$\\rho_3$$'] <- 3
df['$$\\rho_4$$'] <- 4
df['$$\\rho_5$$'] <- 5
# workaround to get rid of first column
df[ , names(df)[-1]]
})
output$table <- DT::renderDataTable(rownames = FALSE, {
isolate(df())
})
}
runApp(shinyApp(ui = ui, server = server), launch.browser = TRUE)