Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move predicates into own package #124

Closed
hadley opened this issue Nov 9, 2015 · 18 comments
Closed

Move predicates into own package #124

hadley opened this issue Nov 9, 2015 · 18 comments
Labels
feature a feature request or enhancement

Comments

@hadley
Copy link
Member

hadley commented Nov 9, 2015

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

@gaborcsardi
Copy link
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.

@smbache
Copy link
Member

smbache commented Nov 9, 2015

+1

@smbache
Copy link
Member

smbache commented Nov 9, 2015

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

@gaborcsardi
Copy link
Member

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

@jennybc
Copy link
Member

jennybc commented Nov 9, 2015

@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

@lionel-
Copy link
Member

lionel- commented Nov 9, 2015

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 ;)

@smbache
Copy link
Member

smbache commented Nov 9, 2015

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

@smbache
Copy link
Member

smbache commented Nov 9, 2015

With a cat hex logo

@gaborcsardi
Copy link
Member

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

@hadley
Copy link
Member Author

hadley commented Nov 9, 2015

I do like predrcats!

@imanuelcostigan
Copy link

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.

@smbache
Copy link
Member

smbache commented Jan 9, 2016

@imanuelcostigan is_na %>% is_na

@imanuelcostigan
Copy link

@smbache ?

@smbache
Copy link
Member

smbache commented Jan 9, 2016

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

@imanuelcostigan
Copy link

ok LOLz

@imanuelcostigan
Copy link

@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.

@imanuelcostigan
Copy link

Starting predrcats package

@hadley
Copy link
Member Author

hadley commented Mar 3, 2017

Will be moving into rlang

@hadley hadley added the feature a feature request or enhancement label Mar 3, 2017
@hadley hadley closed this as completed in 0b11cc0 Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

6 participants