title: Row matrix minus vector with Rcpp
body: <p>I am mainly R user, but I would like to learn <strong>Rcpp</strong> to improve my coding(speed). So I start out playing around with <strong>C++</strong> and <strong>Rcpp</strong>, I thought I’d just try to write the following simple function which takes the row of matrix, (i.e first row) and deduct a vector from it (m[1,]-vec). </p>
  
  <p>I know this sound silly and simple but I am not able to get it work.  </p>
  
  <blockquote>
    <p>  code &lt;- '<br/>   arma::mat beta =
    Rcpp::as(beta_);<br/>   arma::vec y =
    Rcpp::as(y_);<br/>   arma::rowvec S= beta.row(0);<br/><br>
    arma::vec d = S - y;<br/>   return Rcpp::wrap(d);<br/>  '<br/> fun &lt;-
    cxxfunction(signature(beta_ ="matrix",y_="numeric"),code,
    plugin="RcppArmadillo")<br/> m &lt;- matrix(1:9,3)<br/> vec &lt;-
    c(1,2,5)<br/> fun(m,vec)<br/>
    <strong>Error in fun(m, vec) :</strong></p>
    
    <p>in R this wil be done as,<br/>  m[1,]-vec<br/>  0 2 2</p>
  </blockquote>