Reputation: 8404
I have a shinydashboard with 3 tabItems. In the 3rd which is named Results
a rmd file is displayed. The issue is that as soon as I open this tab and display the rmd report the body in the other tabs is spoiled and its like a second dashboard is included inside the main body. Any idea why this happens?
The ex.rmd file
---
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)
and the app.r file
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)))
})
}
)
)
Upvotes: 0
Views: 47
Reputation: 21297
rmd code adds the property
max-width: 800px;
To remove it you can use fragment.only option
HTML(markdown::markdownToHTML(knit('exx.rmd', quiet = TRUE), fragment.only=TRUE))
Alternatively, you can add the following to your ui
.
tags$head(tags$style(HTML("
body {
width: 100% !important;
max-width: 100% !important;
}
")))
Then there is no impact on the previous tabs.
Upvotes: 1