On 29 March 2012 at 18:51, Patrick Burns wrote: | On 29/03/2012 18:33, Dirk Eddelbuettel wrote: | > | > On 29 March 2012 at 19:12, Romain Francois wrote: | > | Le 28/03/12 13:56, Ulrich Bodenhofer a écrit : | > |> Hi, | > |> | > |> My question is the following: is there any way of checking in whether a | > |> component of an Rcpp list (or vector) with a given name exists in this | > |> list. If I simply try accessing a non-existing component, I get an | > |> "index out of bounds" error. Trying to catch a possible exception did | > |> not work either. I also browsed the Rcpp package source code, but | > |> unfortunately I got lost. Sorry if this has been addressed on this list | > |> before. At least I googled in many different ways, but could not find | > |> anything. Any ideas? Any help is gratefully appreciated! | > |> | > |> Thanks and best regards, | > |> Ulrich | > | | > | Hello, | > | | > | I commited the has_element_called method on the Vector template (vectors | > | of all sorts, incl lists). | > | > +1, but how about just calling it 'contains' rather 'has_element_called' ? | | I think 'contains' would imply a value | in the vector rather than a name. The | extra typing might be worth avoiding | that confusion.
While that is true, it cannot deflect away from the fact that Hadley and I are in a deadly mano-a-mano battle about the extended use, or, in my case, strict avoidance, of underscores. That is /extremely serious/ business. So how about hasElementCalled() then? Or given that these are 'names' how about hasElementNamed() pr maybe containsName() Dirk -- R/Finance 2012 Conference on May 11 and 12, 2012 at UIC in Chicago, IL See agenda, registration details and more at http://www.RinFinance.com _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel