Skip to content
Prev 896 / 12125 Next

[R-pkg-devel] Absent variables and tibble

Hadley's note on partial matching has me scared the most concerning the as.null() coding. So the need for a hasName() (or whatever) function seems all the more compelling, and that it be in base R. Perhaps it should be generic, with a default method that searches in the names attribute, potentially extensible to other classes.

Thanks so much, several of you, for your positive and helpful responses.

Russ

-----Original Message-----
From: Duncan Murdoch [mailto:murdoch.duncan at gmail.com] 
Sent: Monday, June 27, 2016 12:50 PM
To: Hadley Wickham <h.wickham at gmail.com>; Lenth, Russell V <russell-lenth at uiowa.edu>
Cc: r-package-devel at r-project.org
Subject: Re: [R-pkg-devel] Absent variables and tibble
On 27/06/2016 1:09 PM, Hadley Wickham wrote:
Yes, I'd consider it.  I think hasName() would be more consistent with other has*() functions in the R sources.

I guess the implementation should be defined to be equivalent to

hasName <- function(x, name)
   name %in% names(x)

though it would make sense to make a faster internal implementation;
!is.null(df$x) is quite a bit faster than "x" %in% names(df).

Duncan Murdoch