通过闪亮包装R在浏览器中显示符号

dmi*_*try 8 symbols r shiny

我的闪亮应用程序中有以下数字输入:

numericInput(
 inputId = "beta",
 label = "beta:",
 value = 0.05,
 step = 0.01
),
Run Code Online (Sandbox Code Playgroud)

是否可以在网络浏览器中显示"beta"作为希腊符号而不是字符串"beta"?

提前致谢.

jdh*_*son 7

以下适用于我:

numericInput(
  inputId = "beta",
  label = HTML("β:"),
  value = 0.05,
  step = 0.01
)
Run Code Online (Sandbox Code Playgroud)

所以替换beta β,它应该在浏览器中呈现为β.HTML用于标记文本如此闪亮不执行转义.

编辑:执行更多涉及的操作mathjax很有用.以下是ui.R调用MathJax库的示例:

library(shiny)

shinyUI(pageWithSidebar(

  # Application title
  headerPanel("New Application"),
  # Sidebar with a slider input for number of observations
  sidebarPanel(
    tags$head( tags$script(src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full", type = 'text/javascript'),
               tags$script( "MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});", type='text/x-mathjax-config')
    ),
    numericInput(
      inputId = "beta",
      label = HTML("$$ \\beta_1 $$"),
      value = 0.05,
      step = 0.01
    )
  ),
  # Show a plot of the generated distribution
  mainPanel(
    plotOutput("distPlot")
  )
))
Run Code Online (Sandbox Code Playgroud)