shiny - 在 Shiny 中向 Markdown 添加公式时出现问题

标签 shiny

我想在包含一些公式的 tabPanel 中添加文本。用户界面如下所示:

library(markdown)
library(shiny) 

shinyUI(fluidPage(
  titlePanel("Test"),
      sidebarLayout(
        sidebarPanel(
          ),

    mainPanel(
      tabsetPanel(
        tabPanel('Text', includeMarkdown("post.rmd"))
        )

      )
    )
  )
)

Markdown 文件如下所示:

This  is a text test.

### Equations
There are inline equations such as $y_i = \alpha + \beta x_i + e_i$.

And displayed formulas:

$$\frac{1}{1+\exp(-x)}$$

当我运行这个时,我没有得到想要的公式,而是得到了上面的文本。 我已按照以下指示进行操作 here

并将格式更改为.md,但它不起作用。我做错了什么?

最佳答案

在链接的讨论中,有关于渲染 rmarkdown 文件的评论。 Rshiny 不会自动将 markdown 文件渲染为 html,因此您必须添加:rmarkdown::render("post.Rmd")。您还可以预先将 Markdown 文件编译为 html 并使用 includeHtml 在这种情况下只需使用代码:includeHTML(("post.html"))

library(markdown)
library(shiny) 
server <- function(input, output) {

}

ui <- shinyUI(fluidPage(
  sidebarLayout(
    sidebarPanel(

    ),
    mainPanel(
          tabsetPanel(
        tabPanel('Text', includeMarkdown(rmarkdown::render("post.rmd")))
        )

    )
  )
))

shinyApp(ui = ui, server = server)

关于shiny - 在 Shiny 中向 Markdown 添加公式时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27557122/

相关文章:

r - Shiny 的应用程序在移动设备上加载时挂起并显示 'please wait' 消息 (R)

r - 使用 Shiny 时的临时文件

html - 调整 R shiny 中框面板的大小

r - 通过 URL 获取数据的 Shiny 应用程序在本地工作,但在 shinyapps.io 上不工作

javascript - 在 Shiny 的 textOutput() 更改后触发 react

r - 我可以在 Shiny 的 onSessionEnded 事件中访问 session 值吗?

r - 在 ReactiveValues 中插入 react 值

R Shiny 错误 : object input not found

javascript - 添加单选按钮以在 Shiny 中选择数据表行

r - Highcharter R 对数轴自定义按钮