<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Rcpp-devel list,<div><br></div><div>I would like to subset a matrix by only selecting certain rows.</div><div><br></div><div>Something like the below…where y is a vector of integers that represent the rows to be selected. However the below does not seem to work.</div><div><br></div><div><div>// [[Rcpp::export]]</div><div>Rcpp::NumericMatrix ss(SEXP X_,SEXP y_){</div><div>  Rcpp::NumericMatrix X(X_)</div><div>  Rcpp::NumericVector y(y_)</div><div>  return X[y];</div><div>}</div><div><br></div><div>R> ss(matrix(rnorm(90),ncol=3),c(1,5,12,22))</div><div><br></div></div><div>It is a bit similar to this question <a href="http://stackoverflow.com/questions/13038256/subset-of-a-rcpp-matrix-that-matches-a-logical-statement">http://stackoverflow.com/questions/13038256/subset-of-a-rcpp-matrix-that-matches-a-logical-statement</a> however rather than just a single value, the find it for a vector.</div><div><br></div><div>also I am not too sure to what extent the Armadillo submat function is able to say subset for example rows: 1,5, 12 and 22 and then call the resulting matrix something else?</div><div><br></div><div>I was hoping that this subsetting procedure was going to be easy…but I seem to have got stuck.</div><div><br></div><div>thanks</div><div><br></div><div>HLM</div><div><br></div></body></html>