I'm trying to output a graph in an R Markdown HDML output. Currently the graph is too big, so it creates a scroll bar to let you see the whole thing, which I dislike. I'd like to remove the scroll bar without decreasing the figures size.
Unfortunately, shiny (or at least the way I've used shiny) seems to be having issues with the normal methods of doing this. Setting fig.height = 40 in the chunk settings doesn't do anything, and increasing the height in plotOutput increases the graph height without removing the scroll bar. I don't have this problem with a standard Rscript, so it's definitely an Rmarkdown thing.
Any help would be greatly appreciated.
library(tidyverse)
library(shiny)
server <- function(input, output, session) {
trends <- reactive({
req(input$sel_year)
mpg %>%
filter(year %in% input$sel_year)
})
output$plot <- renderPlot({
ggplot(
data = trends(),
mapping = aes(x = trans)
) +
geom_bar()
})
}
ui <- fluidPage(
selectInput(
inputId = "sel_year",
label = "Choose Year",
list("1999", "2008")
),
plotOutput("plot")
)
shinyApp(ui = ui, server = server)