【发布时间】:2020-12-01 00:07:47
【问题描述】:
我有一个带有 3 个 tabItems 的闪亮仪表板。在名为Results 的第三个文件中显示了一个rmd 文件。问题是,一旦我打开此选项卡并显示 rmd 报告,其他选项卡中的正文就被破坏了,就像第二个仪表板包含在主体中一样。知道为什么会这样吗?
ex.rmd 文件
---
title: "An example Knitr/R Markdown document"
output: html_document
---
{r chunk_name, include=FALSE}
x <- rnorm(100)
y <- 2*x + rnorm(100)
cor(x, y)
和 app.r 文件
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
library(knitr)
dbHeader <- dashboardHeaderPlus(
)
shinyApp(
ui = dashboardPagePlus(
header = dbHeader,
sidebar = dashboardSidebar(
sidebarMenu(id = "sidebar", # id important for updateTabItems
menuItem("Welcome", tabName = "well", icon = icon("house")),
menuItem("Consent", tabName = "conse", icon = icon("line-chart")),
menuItem("Results", tabName = "res", icon = icon("line-chart"))
) ),
body = dashboardBody(
useShinyjs(),
tags$script(HTML("$('body').addClass('fixed');")),
tags$head(tags$style(".skin-blue .main-header .logo { padding: 0px;}")),
tabItems(
tabItem("well",
fluidRow(
column(5,),
column(6,
actionButton("button", "Get started",style='padding:4px; font-size:140%')))),
tabItem("conse",
fluidRow(column(3,h3("Concent"))),
fluidRow(column(3,h5(strong("Purpose of the research")))),
fluidRow(column(12,"Your practice is being invited to participate in a study which aims to explore the relationship of statin prescriptions and all cause mortality in elderly general practice patients")),
),
tabItem("res",
tags$hr(),
fluidRow(
column(3,actionButton('spdf', "Save PDF",style='padding:4px; font-size:180%')
),
column(6,
uiOutput('markdown'))))
),
)
),
server<-shinyServer(function(input, output,session) {
output$markdown <- renderUI({
HTML(markdown::markdownToHTML(knit('ex.rmd', quiet = TRUE)))
})
}
)
)
【问题讨论】:
标签: r shiny markdown shinydashboard