在tabItem中创建r-.Rmd输出后,在闪亮的面板的所有tabItem的主体中创建第二个面板



我有一个带有3个tabItems的shinydashboard。在名为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)

和应用程序.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)))
})
}
)
)

rmd代码添加属性

max-width: 800px;

要删除它,您可以使用碎片。仅选项

HTML(markdown::markdownToHTML(knit('exx.rmd', quiet = TRUE), fragment.only=TRUE))

或者,您可以将以下内容添加到ui中。

tags$head(tags$style(HTML("
body {
width: 100% !important;
max-width: 100% !important;
}
")))

这样就不会对以前的选项卡产生影响。

最新更新