[Rcpp-devel] Odd-seeming behaviour of [[ and $
romain at r-enthusiasts.com
Mon Oct 22 20:05:19 CEST 2012
Le 22/10/12 11:17, North, Ben a écrit :
> Hi Romain,
> Thanks for the reply.
>>> The fact that 'x[["value"]]' finds the method only if I've first done
>>> 'x$value' seemed odd.
>> This is an implementation artefact. In short, you are not supposed to
>> use [[.
> OK, fair enough :)
> Because `$` doesn't evaluate its field-name argument, is
> field.name <- "value"
> do.call(`$`, list(x, field.name))
> the recommended way of accessing methods whose names are computed at
> run-time? It does work; just wondering if there's a better way.
I don't have anything else for you.
At this stage, I would however ask myself "do I __really__ need this at
Professional R Enthusiast
+33(0) 6 28 91 30 30
R Graph Gallery: http://gallery.r-enthusiasts.com
|- http://bit.ly/xbKv0R : Crawling facebook with R
|- http://bit.ly/v3WB8S : ... And now for solution 17, still using Rcpp
`- http://bit.ly/uaQDGr : int64: 64 bit integer vectors for R
More information about the Rcpp-devel