我想在我闪亮的仪表板应用程序中显示带有 LaTeX 方程的 Rmd 文件。我在使用时遇到了问题includeMarkdown()
and includeHTML()
。这是我想要实现的目标的简化应用程序。这是我的应用程序。R:
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title='My test application'),
dashboardSidebar(
sidebarMenu(
menuItem("Theory", tabName = "theory", icon = icon("book"))
)
),
dashboardBody(
tabItems(
tabItem(tabName="theory",
includeMarkdown("Theory.Rmd")
#includeMarkdown("Theory.md")
#includeHTML("Theory.html")
)
)
)
)
server <- function(input, output){
}
shinyApp(ui = ui, server = server)
我的 Theory.Rmd 文件:
---
title: "Theory"
output:
html_document:
mathjax: "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
---
Here is an equation:
$$Q = a(h − c)^b$$
请注意,为了运行应用程序,Theory.Rmd 和 app.R 必须保存在同一目录(例如工作目录)中,并且必须具有这些确切的名称。
要获取 Rmd 文件的 markdown Theory.md 文件,只需执行以下操作:
library(knitr)
knit("Theory.Rmd","Theory.md")
并获得Theory.html
文件,只需按 Theory.Rmd 文件中的 Knit to HTML 按钮
When running my app in my browser or RStudio window, includeMarkdown("Theory.Rmd")
or includeMarkdown("Theory.md")
, do not render the equations but it starts by default in the theory menu item, like this:
However using includeHTML("Theory.html")
the equations render correctly but the screen display is shortened, and by default it does not start in any menu item, like this:
but when clicked on theory I get correctly rendered equations:
有没有办法来解决这个问题?非常感谢!