title: Rcpp NumericMatrix - how to erase a row / column?
body: <p>A novice question as I learn the Rcpp classes / data structures: Is there a member function to erase a row / column for an object of class <code>Rcpp::NumericMatrix</code>? (Or other types of <code>type **Matrix</code> -- I'm assuming it's a template class)?</p>
  
  <pre><code>library(Rcpp)
  cppFunction('
    NumericMatrix sub1 {NumericMatrix x, int&amp; rowID, int&amp; colID) {
      // let's assume separate functions for rowID or colID
      // but for the example case here
      x.row(rowID).erase(); // ??? does this type of member function exist?
      x.col(colID).erase(); // ???
      return x;
  }')
  </code></pre>
  
  <p>If this type of member function doesn't exist, how about this?</p>
  
  <pre><code>cppFunction('NumericMatrix row_erase (NumericMatrix&amp; x, int&amp; rowID) {
    // a similar function would exist for removing a column.
    NumericMatrix x2(Dimension(x.nrow()-1, x.ncol());
    int iter = 0; // possibly make this a pointer?
    for (int i = 0; i &lt; x.nrow(); i++) {
      if (i != rowID) {
        x2.row(iter) = x.row(i);
        iter++;
      }
    }
    return x2;
  }')
  </code></pre>
  
  <p>Or perhaps we wish to remove a set of rows/columns:</p>
  
  <pre><code>cppFunction('NumericMatrix row_erase (NumericMatrix&amp; x, IntegerVector&amp; rowID) {
    // a similar function would exist for removing a column.
    rowID = rowID.sort();
  
    NumericMatrix x2(Dimension(x.nrow()- rowID.size(), x.ncol());
    int iter = 0; // possibly make this a pointer?
    int del = 1; // to count deleted elements
    for (int i = 0; i &lt; x.nrow(); i++) {
      if (i != rowID[del - 1])
        x2.row(iter) = x.row(i);
        iter++;
      } else {
        del++;
      }
    }
    return x2;
  }')
  </code></pre>