title: R Shiny: reactiveValues vs reactive
body: <p>This question is related to <a href="https://stackoverflow.com/questions/18324397">this one</a>. The two can generate the same functionality, but implementation is slightly different. One significant difference is that a <code>reactiveValue</code> is a container that can have several values, like <code>input$</code>. In <a href="http://shiny.rstudio.com/articles/reactivity-overview.html" rel="noreferrer">shiny documentation</a> functionality is usually implemented using <code>reactive()</code>, but in most cases I find <code>reactiveValues()</code> more convenient. Is there any catch here? Are there any other major differences between the two that I might not be aware off?  Are these two code snippets equivalent?</p>
  
  <p>See the same <a href="http://shiny.rstudio.com/articles/reactivity-overview.html" rel="noreferrer">example code</a>  implemented using:</p>
  
  <ol>
  <li><p>a reactive expression:</p>
  
  <pre><code>library(shiny)
  
  ui &lt;- fluidPage( 
    shiny::numericInput(inputId = 'n',label = 'n',value = 2),
    shiny::textOutput('nthValue'),
    shiny::textOutput('nthValueInv')   
  )
  
  fib &lt;- function(n) ifelse(n&lt;3, 1, fib(n-1)+fib(n-2))
  
  server&lt;-shinyServer(function(input, output, session) {   
    currentFib         &lt;- reactive({ fib(as.numeric(input$n)) })  
    output$nthValue    &lt;- renderText({ currentFib() })
    output$nthValueInv &lt;- renderText({ 1 / currentFib() })   
  })
  
  shinyApp(ui = ui, server = server)
  </code></pre></li>
  <li><p>a reactive value:</p>
  
  <pre><code>library(shiny)
  
  ui &lt;- fluidPage( 
    shiny::numericInput(inputId = 'n',label = 'n',value = 2),
    shiny::textOutput('nthValue'),
    shiny::textOutput('nthValueInv')  
  )
  
  fib &lt;- function(n) ifelse(n&lt;3, 1, fib(n-1)+fib(n-2))
  
  server&lt;-shinyServer(function(input, output, session) { 
    myReactives &lt;- reactiveValues()  
    observe(  myReactives$currentFib &lt;-  fib(as.numeric(input$n))  ) 
    output$nthValue    &lt;- renderText({ myReactives$currentFib  })
    output$nthValueInv &lt;- renderText({ 1 / myReactives$currentFib  }) 
  })
  
  shinyApp(ui = ui, server = server)
  </code></pre></li>
  </ol>