I have tried this:
output$plot <- renderPlot({
getPlot()
}, width=input$plotX, height=input$plotY) # referring to two numericInput boxes
But I get this error:
Error in .getReactiveEnvironment()$currentContext() : Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
The help text suggests that I use functions, and that within those functions I can refer to reactive values, etc. But having done something like that, I still get the same error...
Is there a way to allow users to resize the plot based on values they enter into the app?
You can wrap a reactive value into a function using shiny:::exprToFunction.
For example,
output$plot <- renderPlot({
getPlot()
}, width=exprToFunction(input$plotX),
height=exprToFunction(input$plotY)))
should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With