Skip to content

Move predicates into own package #124

Closed

Description

@hadley

Since they're useful in many places

@gaborcsardi do you already have a mini package for predicates? In purrr, we have:

is_atomic <- function(x) {
  typeof(x) %in% c("logical", "integer", "double", "complex", "character", "raw")
}
is_vector <- function(x) {
  is_atomic(x) || is.list(x)
}
is_bare_list <- function(x) {
  !is.object(x) && is_list(x)
}

etc

Activity

  1. gaborcsardi commented on Nov 9, 2015

    @gaborcsardi
    Member

    Micropackage. :) Not yet. But happy to have one. :)

    We just want them to return TRUE/FALSE? I often find it useful if they can also return an error message.

  2. smbache commented on Nov 9, 2015

    @smbache
    Member

    +1

  3. smbache commented on Nov 9, 2015

    @smbache
    Member

    I think true / false is best (more generally applicable). But perhaps as attribute.

  4. gaborcsardi commented on Nov 9, 2015

    @gaborcsardi
    Member

    Btw. there are already a lot of assertions in the assertive.* packages, e.g. http://www.r-pkg.org/pkg/assertive.numbers

  5. jennybc commented on Nov 9, 2015

    @jennybc
    Member

    @gaborcsardi: following that link made me realize that 14 of the 16 assertive.* packages don't seem to be in the METACRAN mirror?

    https://github.com/search?q=user%3Acran+assertive&type=Repositories

  6. lionel- commented on Nov 9, 2015

    @lionel-
    Member

    Instead of a micro-package, do we need a "standard lib" package with underscored function names and sane behaviours? This would be a good home for set_names() (#119) etc. Could be called lowliner ;)

  7. smbache commented on Nov 9, 2015

    @smbache
    Member

    Or if only for predicates, "predrcats" ;-)

  8. smbache commented on Nov 9, 2015

    @smbache
    Member

    With a cat hex logo

  9. gaborcsardi commented on Nov 9, 2015

    @gaborcsardi
    Member

    @jennybc yeah, the GitHub mirroring is not working now, I'll fix it soon.

  10. hadley commented on Nov 9, 2015

    @hadley
    MemberAuthor

    I do like predrcats!

  11. imanuelcostigan commented on Jan 9, 2016

    @imanuelcostigan

    Is there a reason why is_na is not available ? I am happy to help transport these predicates to a separate package if help is needed.

  12. smbache commented on Jan 9, 2016

    @smbache
    Member

    @imanuelcostigan is_na %>% is_na

  13. imanuelcostigan commented on Jan 9, 2016

    @imanuelcostigan
  14. smbache commented on Jan 9, 2016

    @smbache
    Member

    Just found it amusing that you point out that is_na is not available (i.e. is_na)... :-)

  15. imanuelcostigan commented on Jan 9, 2016

    @imanuelcostigan

    ok LOLz

  16. imanuelcostigan commented on Mar 18, 2016

    @imanuelcostigan

    @lionel- i have been also been thinking that something like that would be sweet.

    Been reading Swift's API design guidelines (ugh...camelCase) and reflecting on the lack of design principles in R's core packages (not just camelCase vs snake_case). That isn't surprising given its genesis.

  17. imanuelcostigan commented on Apr 16, 2016

    @imanuelcostigan
  18. hadley commented on Mar 3, 2017

    @hadley
    MemberAuthor

    Will be moving into rlang

  19. added a commit that references this issue on Jan 10, 2025
    0b11cc0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions