Hello everbody,
I am trying to create a dynamic Shiny Boxplot where the user can also changing the y-axis range value as they want. Here is just an example using the mtcars data:
library(shiny)
library(ggplot2)
ui <- fluidPage(
titlePanel("Boxplot"),
sidebarLayout(
sidebarPanel(
textInput("yAxisRange","Y-axis range (eg., '0,10'):")
),
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
ggplot(mtcars, aes_string(x=as.factor(mtcars$vs),y=mtcars$mpg)) +
stat_boxplot(geom ='errorbar', width = 0.5) + #add end of the whisker line
geom_boxplot(outlier.shape = NA)+
coord_cartesian(ylim = c(input$yAxisRange)) #change the y-axis range
})
}
# Run the application
shinyApp(ui = ui, server = server)
and it gives an error "missing value where TRUE/FALSE needed". Can someone help me with this one? thank you!