[Rcpp-devel] Matrix rows/columns

Cedric Ginestet c.ginestet05 at googlemail.com
Mon Dec 20 12:11:02 CET 2010


Dear Rcpp users and developers,

I seem to be unable to understand how to extract a row/column from an 
Rcpp Matrix. Here are some reproducible codes:

###############################
library(Rcpp);
library(inline)
src <- '
IntegerMatrix D;
   IntegerVector Drow = D.row(1);
return Drow;
'
rowExtraction <- 
cxxfunction(signature(D="matrix"),body=src,plugin="Rcpp",verbose=TRUE)
D <- matrix(1:9,3,3)
rowExtraction(D)
################################

Although this code compile, I get the following error when executing 
rowExtraction:
Error in rowExtraction(D) : index out of bounds

How can I extract a row into an Rcpp:vector?

Thanks for your help,
Cedric


>
>


More information about the Rcpp-devel mailing list