【问题标题】:Display symbols in browser via shiny package R通过闪亮的包R在浏览器中显示符号
【发布时间】:2014-01-07 14:36:03
【问题描述】:

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

numericInput(
 inputId = "beta",
 label = "beta:",
 value = 0.05,
 step = 0.01
),

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

提前致谢。

【问题讨论】:

    标签: r symbols shiny


    【解决方案1】:

    它应该与使用 expression(beta) 的基础 R 中的相同。我还没有尝试过闪亮的,但它应该可以工作。

    【讨论】:

      【解决方案2】:

      以下对我有用:

      numericInput(
        inputId = "beta",
        label = HTML("β:"),
        value = 0.05,
        step = 0.01
      )
      

      所以将 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")
        )
      ))
      

      【讨论】:

      • 谢谢!以及如何指定索引?在基础 R 中,我会使用表达式(beta[1])。
      • App 部署后,MathJax 的功能丢失了 :(。部署后我该怎么做才能让它继续工作?
      • @And 部署是指shinyapps.io 吗?我不确定他们运行的是什么版本的闪亮服务器。最好问groups.google.com/forum/#!forum/shinyapps-users
      • @jdharrison 确切地说,deployApp()!
      • 未来注意事项:cdn.mathjax.org 即将结束生命周期,请查看mathjax.org/cdn-shutting-down 了解迁移提示。
      猜你喜欢
      • 1970-01-01
      • 2015-03-23
      • 1970-01-01
      • 1970-01-01
      • 2016-06-09
      • 1970-01-01
      • 2019-08-20
      • 2012-12-20
      • 2022-01-11
      相关资源
      最近更新 更多