-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I'm splitting parts of my shinymeta output into separate chunks; however, to avoid duplicate code, I'm having all of the chunks share the same expansionContext. Here's a small reproducible example cobbled together based on existing shinymeta examples:
library(shiny)
library(shinymeta)
library(dplyr)
ui <- fluidPage(
selectInput("dataset", "Dataset", c("iris", "pressure")),
varSelectInput("col_x", "column for x", NULL),
varSelectInput("col_y", "column for y", NULL),
verbatimTextOutput("code_1"),
verbatimTextOutput("code_2"),
verbatimTextOutput("code_3"),
plotOutput("plot")
)
server <- function(input, output, session) {
df <- metaReactive({
get(..(input$dataset), "package:datasets")
})
observeEvent(df(), {
updateVarSelectInput(session, "col_x", data = df())
updateVarSelectInput(session, "col_y", data = df())
})
output$plot <- metaRender(renderPlot, {
"# This is a helpful comment"
ggplot(..(filtered())) +
geom_point(aes(x = !!..(input$col_x), y = !!..(input$col_y)))
})
filtered <- metaReactive({
..(df()) %>% distinct()
})
exp_ctx <- newExpansionContext()
output$code_1 <- renderPrint({
expandChain(.expansionContext = exp_ctx,
quote(library(magrittr)),
quote(library(ggplot2))
)
})
output$code_2 <- renderPrint({
expandChain(.expansionContext = exp_ctx,
invisible(filtered())
)
})
output$code_3 <- renderPrint({
expandChain(.expansionContext = exp_ctx,
output$plot()
)
})
}
shinyApp(ui, server)This app loads fine and the chunks look great:
However, when you then change the selected dataset, the middle chunk just disappears:
Any thoughts? Am I missing something in the way I'm implementing the expansionContext?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

