r - Rcpp sugar for NumericMatrix -
for numericvector, can subset smaller numericvector using integervector contains positions subset.
e.g. suppose x<-c(1,2,2,3,4,5), idx<-c(1,3,4), , xsub<-x[idx] 1 2 3.
within rcpp, can use xsub=x[idx].
is there similar way subset rows of numericmatrix using integervector?
for example, following code xmatsub=xmat(idx,_) didn't work me.
there isn't way. have manually, not complicated.
numericmatrix res( idx.size(), m.rows() ) ; for( int i=0; i<idx.size(); i++){ res.row(i) = m.row(idx[i]-1) ; }
Comments
Post a Comment