[Rcpp-devel] indexing matrix by row names and column names

Mahdi Shafiei shafiei at cs.dal.ca
Wed Mar 2 17:18:56 CET 2011


Hello,
In R, one can define a matrix and assign names to tows and columns:

A = matrix(1:9, nrow=3, ncol=3);
rownames(A) = c("R1", "R2", "R3")
colnames(A) = c("C1", "C2", "C3")

and then access entries in A by these row and column names instead of row
and column numbers like:

A["R1", "C1"]

I tried to find out if this is possible in some way in Rcpp for Matrix type.
I know that one can set rownames and colnames attributes for an object of
type Matrix but my understanding is that this is done for preparing an
object to be passed to R.

Is there a way to retrieve entries of a let say NumericMatrix by row and
column names  ?

thanks,
Mahdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110302/56ed3a58/attachment.htm>


More information about the Rcpp-devel mailing list