The following is the simplified R Shiny app code to include a HTML file converted from a R markdown file using rmarkdown
library.
library(shiny)
library(shinydashboard)
library(rmarkdown)
ui <- dashboardPage(
dashboardHeader(title = "Basic Dashboard"),
dashboardSidebar(
sidebarMenu(id="menu1",
menuItem("tab title1", tabName = "name1",
icon = icon("sliders")),
menuItem("tab title2", tabName = "name2",
icon = icon("sliders"))
),
conditionalPanel(
condition = "input.menu1 == 'name2'",
selectInput("period", "Period:",
choices = list("Years" = 1, "Months" = 2))
)
),
dashboardBody(
tabItem(tabName = 'name1', uiOutput("about"))
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
if (!file.exists("www/about.html") || file.info("www/about.Rmd")$mtime >
file.info("www/about.html")$mtime) {
# Convert the Rmd file to HTML
rmarkdown::render("www/about.Rmd", clean = TRUE, quiet = TRUE)
}
output$about <- renderUI({
includeHTML("www/about.html")
})
}
# Run the application
shinyApp(ui = ui, server = server)
The R markdown file is simply stating:
---
title: "About Page"
output:
html_document:
theme: yeti
---
## About Page
Whenever the HTML file is included as shown above, the conditional panel is not working.
Looks like there are some conflicts between the scripts used by R Shiny Dashboard and rmarkdown
theme. I wonder there are ways to prevent such conflicts while maintaining the theme of Rmd-based HTML and enabling the conditional panel functionalities.