-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Managing complicated control flow #83
Comments
There are a couple different ways to currently approach this problem. The most straight-forward would be to duplicate code in each case (just make sure to that you're always returning a output$plot <- metaRender2(renderPlot, {
if (input$bins<=30) {
metaExpr(ggplot(faithful, aes_string(..(input$column))) + geom_histogram(bins = ..(input$bins)) + theme_dark())
} else {
metaExpr(ggplot(faithful, aes_string(..(input$column))) + geom_histogram(bins = ..(input$bins)) + theme_bw())
}
}) Clearly that's not ideal if there's lots of code that needs duplicating. A more sophisticated approach that avoids duplication might be through clever use of output$plot <- metaRender2(renderPlot, {
my_theme <- if (input$bins<=30) quote(theme_dark()) else quote(theme_bw())
metaExpr({
p <- ggplot(faithful, aes_string(..(input$column)))
p <- p + geom_histogram(bins = ..(input$bins))
p + eval(..(my_theme))
})
}) This generates valid code, but it's also not ideal in that it generates code that has an unnecessary I don't immediately see an approach that both avoids duplication and generates "perfectly human-like" code...maybe @jcheng5 can think of a better alternative? |
metaRender
Hello, |
Hello and thank you for your package.
In this example, what is the correct way to write the condition inside
metaRender
for a better display with theShow code
button.Here, the
Show code
button show :I would like it to simply display:
Many thanks in advance for your support!
The text was updated successfully, but these errors were encountered: