[Rd] subset data.frame at C level

Jim Hester j@me@@|@he@ter @end|ng |rom gm@||@com
Tue Jun 23 22:11:42 CEST 2020


It looks to me like internally .subset2 uses `get1index()`, but this
function is declared in Defn.h, which AFAIK is not part of the exported R
API.

 Looking at the code for `get1index()` it looks like it just loops over the
(translated) names, so I guess I just do that [0].

[0]:
https://github.com/r-devel/r-svn/blob/1ff1d4197495a6ee1e1d88348a03ff841fd27608/src/main/subscript.c#L226-L235

On Wed, Jun 17, 2020 at 6:11 AM Morgan Morgan <morgan.emailbox using gmail.com>
wrote:

> Hi,
>
> Hope you are well.
>
> I was wondering if there is a function at C level that is equivalent to
> mtcars$carb or .subset2(mtcars, "carb").
>
> If I have the index of the column then the answer would be VECTOR_ELT(df,
> asInteger(idx)) but I was wondering if there is a way to do it directly
> from the name of the column without having to loop over columns names to
> find the index?
>
> Thank you
> Best regards
> Morgan
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list