我的 Shiny 应用中有以下数字输入:
numericInput(
inputId = "beta",
label = "beta:",
value = 0.05,
step = 0.01
),
是否可以在 Web 浏览器中将“beta”显示为希腊符号而不是字符串“beta”?
提前致谢。
最佳答案
以下对我有用:
numericInput(
inputId = "beta",
label = HTML("β:"),
value = 0.05,
step = 0.01
)
所以用
β
替换 beta它应该在浏览器中呈现为 β。 HTML
用于标记文本如此 Shiny 不会执行转义。编辑:进行更多涉及的操作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")
)
))
关于r - 通过 Shiny 的包 R 在浏览器中显示符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20674697/