Dan_yef Dan_yef - 1 year ago 74
R Question

Is it possible to use reactive function into another reactive function in r shiny?

For example:

data_cbs <- reactive({

model <- reactive({
data <- data_cbs()
+ "code"

Is it possible to use the following structure in R shiny?

Maybe it is important to know, that
consists of 3-4 "else-if" statements.

Answer Source

Here's a single-script example to show that this indeed works and to play around with:

# Global variables can go here
n <- 200

# Define the UI
ui <- bootstrapPage(
  checkboxInput('random', 'randomize'),

# Define the server code
server <- function(input, output) {

  checkRandom <- reactive({
    if( input$random ){
      data <- runif(n)
    }else {
      data <- seq(1, n)

  output$plot <- renderPlot({

# Return a Shiny app object
shinyApp(ui = ui, server = server)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download