Reputation: 727
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?
Upvotes: 4
Views: 2707
Reputation: 2936
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.
Upvotes: 7