【问题标题】:How to make equation formulas reactive in shiny R?如何使方程式公式在闪亮的 R 中具有反应性?
【发布时间】:2021-08-08 21:27:07
【问题描述】:

我有一些文本,我想放入在修改闪亮应用程序的某些输入时可能会改变的内联公式。我知道如何使用 HTML 动态更改文本:

        
        tags$h4("Statistical hypothesis testing"),
        HTML(paste0("<b>", "H", tags$sub(0), "</b>", ": the variables ", "<b>", input$categorical1, "</b>", " and ", "<b>", input$categorical2, "</b>", " are independent")),
        HTML(paste(br())),
        HTML(paste0("<b>", "H", tags$sub(1), "</b>", ": the variables ", "<b>", input$categorical1, "</b>", " and ", "<b>", input$categorical2, "</b>", " are not independent")),
        
      ) 

但是对于 HTML,我不能引入一些带有求和的公式(据我所知,如果有一种方法可以使用标签引入复杂的公式就可以了)。

另一方面,我找到了一种编写复杂公式的方法,内嵌一些文本,但在这种情况下,我无法像在 HTML 中那样动态更改文本。

【问题讨论】:

标签: r text shiny formula reactive


【解决方案1】:

你可以试试renderUI/uiOutput:

    tags$h4("Statistical hypothesis testing"),
    uiOutput("html")

在服务器中:

output[["html"]] <- renderUI({
  tagList(
        HTML(paste0("<b>", "H", tags$sub(0), "</b>", ": the variables ", "<b>", input$categorical1, "</b>", " and ", "<b>", input$categorical2, "</b>", " are independent")),
        HTML(paste(br())),
        HTML(paste0("<b>", "H", tags$sub(1), "</b>", ": the variables ", "<b>", input$categorical1, "</b>", " and ", "<b>", input$categorical2, "</b>", " are not independent"))
  )
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-04
    • 2018-01-23
    • 1970-01-01
    • 2019-07-16
    • 2022-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多