Is there a way to increase the plot window size in shiny
dependent on the number of facets that are used in a ggplot
figure - perhaps using a vertical scroll.
For example, using the example below, when the input is "A"
there are three facets and the plots look good. When the option "B"
is selected the number of plots increases but the plot window stays the same size resulting in plots that are too small.
Is there a strategy to keep all the panel heights the same, independent of input? Thanks.
library(ggplot2)
library(shiny)
mtcars$cyl = sample(letters[1:5], 32, TRUE)
ui <- fluidPage(
navbarPage(title="title",
tabPanel("One",
column(3,
wellPanel( selectInput('name', 'NAME', c("A", "B")))),
column(9, plotOutput('plot1')))
))
server <- function(input, output) {
X = reactive({input$name == "A"})
output$plot1 <- renderPlot({
if(X()){
p1 = ggplot(mtcars, aes(mpg, wt)) + facet_grid( . ~ gear )
}else{
p1 = ggplot(mtcars, aes(mpg, wt)) + facet_grid( cyl ~ gear )
}
return(p1)})
}
shinyApp(ui, server)