Let's say I want to change the default value of width
in shiny::renderPlot
to 500
. How can I do that?
Below is my try with defining customRenderPlot
function but it doesn't react to input changes later on.
library(shiny)
customRenderPlot <- function(plot, width = 500) {
renderPlot(plot, width = width)
}
ui <- fluidPage(
numericInput(
inputId = "bins",
label = "Number of bins:",
value = 2
),
plotOutput(outputId = "distPlot")
)
server <- function(input, output) {
output$distPlot <- customRenderPlot({
x <- faithful$waiting
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins)
})
}
shinyApp(ui = ui, server = server)