[Rcpp-devel] Equivalent to the which function in Rcpp / Access to a data.frame's indices?

Kevin Ushey kevinushey at gmail.com
Fri Jul 18 22:15:36 CEST 2014


Hi Asis,

Sorry, Rcpp doesn't have vectorized subsetting for rows of a data.frame /
matrix. However, if you want columns, you can use vector subsetting:

    http://gallery.rcpp.org/articles/subsetting/

But perhaps we can consider added 'rows', 'cols' helper methods that would
pull out rows and columns of a data.frame / matrix that satisfy some
predicate.

Cheers,
Kevin


On Fri, Jul 18, 2014 at 9:51 AM, Asis Hallab <asis.hallab at gmail.com> wrote:

> Dear Rcpp-Experts,
>
> in Rcpp I want to quickly identify matching rows in a data.frame.
>
> In R I would do the following:
>
> matching.rows <- my.data.frame[ which(
> my.data.frame$column.of.interest == 'value_of_interest' ), ]
>
> How to do something similar in Rcpp?
> If I am not mistaken R data.frames and matrices do have some implicit
> index, thta allows very fast identification of matching positions,
> don't they?
>
> If it helps I could do that on an Rcpp::Matrix instead of a DataFrame…
>
> Help will be much appreciated.
> Have a pleasant weekend, and
> Cheers!
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140718/11ca6ed2/attachment.html>


More information about the Rcpp-devel mailing list