'Why does this reactive event fail to render in flexdashboard?

I do not understand why the code in this flexdashboard relative to 'Chart C' renders nothing while 'Chart B' code works fine. Obviously there is an issue that is causing this problem. If there is a more efficient means of accomplishing the same task, I am all ears. Could someone please assist?

This is a screenshot of the output.

enter image description here


    ---
    title: "untitled"
    output:
     flexdashboard::flex_dashboard:
       orientation: rows
      
        
    runtime: shiny
    ---
    
    ```{r setup, include=FALSE}
     
     
    knitr::opts_chunk$set(
       echo    = FALSE,
       message = FALSE,
       warning = FALSE
    )
     
     
    library(shiny)
    library(flexdashboard)
     
     
     
    ```
     
    
    
    
    
    
    
    
     
    ```{r}
     
    # Chart A - UI
    
    user_choices <- 1:4       
    
    shiny::selectInput(
                inputId = "data",
                label   = c("Make a selection (1-4)"),
                choices = user_choices,
                selected = "3"                             
      )
     
     
     
    ```
     
     
    
    
    
    
    ```{r}
    
    # Chart B
    
             x1 <- eventReactive(input$data, 
                                 { as.numeric(input$data) }
                                 )
             
             
    renderPrint({
      
      list(
      
      x1(),
      
      x1() == 1,
      
      x1() == 2,
      
      x1() == 3,
      
      x1() == 4
      
     
      )
      
    
      
    })
    
    
    ```
    
    
    
    ```{r}
    
    #  Chart C
    
    
    renderPrint({
      
    
      x1 <- eventReactive( input$data, {
       
     
           if ( x1() == 1) {
                baby <- 12
         } else if ( x1() == 2) {
                baby <- 13
         }  else if ( x1() == 3) {
                baby <- 15
         }    else   {
                baby <- 22
         }
       
       baby
    
       })
    
     })



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source