title: Declare a variable as a reference in Rcpp
body: <p>In C++, we can declare a variable as a reference.</p>
  
  <pre><code>int a = 10;
  int&amp; b = a;
  </code></pre>
  
  <p>If we set <code>b=15</code>, <code>a</code> also changes.</p>
  
  <p>I want to do the similar thing in Rcpp. </p>
  
  <pre><code>List X = obj_from_R["X"];
  IntegerVector x_i = X[index];
  x_i = value;
  </code></pre>
  
  <p>I want to update an object from R called <code>X</code> by inserting a value to one of its vector. The code above did not work, so I tried this:</p>
  
  <pre><code>IntegerVector&amp; x_i = X[index];
  </code></pre>
  
  <p>and received an error.</p>
  
  <pre><code>error: non-const lvalue reference to type 'IntegerVector'
        (aka 'Vector&lt;13&gt;') cannot bind to a temporary of type 'Proxy' (aka 'generic_proxy&lt;19&gt;')
  </code></pre>