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

Logicals on characters? #22

Open
scienceisfiction opened this issue Feb 28, 2016 · 2 comments
Open

Logicals on characters? #22

scienceisfiction opened this issue Feb 28, 2016 · 2 comments

Comments

@scienceisfiction
Copy link

This is probably a dumb question, but does someone know of a simple way to use logicals on characters? The way my data is currently tidied, most of my assertions are about characters, not numbers, for example:

DougsData %>%
  verify(year, (1998|1999)) %>%
  verify(day <= 31) %>%
  verify(length(levels(Location)) == 2) %>%
  verify(genus, ('selasphorus' | 'unknown'))

Is there a simple way to solve the problem of the last line? It would be more informative then just asking R to verify the number of genus (2) if I could make sure all values are exactly 'selasphorus' OR 'unknown'...

@JoeyBernhardt
Copy link

Hey @scienceisfiction,

What if you did something like this?

genera <- c("genus1", "genus2", "genus3")
DougsData %>%
assert(in_set(genera), genus)

Would that work for you?

@scienceisfiction
Copy link
Author

Thanks @JoeyBernhardt !
Worked perfectly--of course it was something we went over in class that I just missed, lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants