input <- list(dataset = "cars")
# varname is only required if srcref aren't supported
# (R CMD check disables them for some reason?)
mr <- metaReactive({
get(..(input$dataset), "package:datasets")
})
top <- metaReactive({
head(..(mr()))
})
bottom <- metaReactive({
tail(..(mr()))
})
obs <- metaObserve({
message("Top:")
summary(..(top()))
message("Bottom:")
summary(..(bottom()))
})
# Simple case
expandChain(obs())
# Explicitly print top
expandChain(top(), obs())
# Separate into two code chunks
exp_ctx <- newExpansionContext()
expandChain(.expansionContext = exp_ctx,
invisible(top()),
invisible(bottom()))
expandChain(.expansionContext = exp_ctx,
obs())
Run the code above in your browser using DataLab