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

expect_equivalent() for categorical data #528

Closed
AmeliaMN opened this issue Sep 15, 2016 · 2 comments
Closed

expect_equivalent() for categorical data #528

AmeliaMN opened this issue Sep 15, 2016 · 2 comments
Labels
expectation 🙀 feature a feature request or enhancement wip work in progress

Comments

@AmeliaMN
Copy link

I know you are using base functions like all.equal() to do the underlying checks, but it would be nice to have a way to check levels in factor variables without getting the ordering precisely right. See https://github.com/dsscollection/factor-mgmt/blob/master/analysis/working_with_factors.Rnw#L394 for an example of what I'm talking about. In essence, I wish that I could run

expect_equivalent(c("Male", "Female"), c("Female", "Male")) 

and get a TRUE.
Maybe this is something more appropriate for https://github.com/hadley/forcats ?

cc @nicholasjhorton

@nicholasjhorton
Copy link

I would think that:

expect_equivalent(c("Male", "Female"), c("Female", "Male"))

should return TRUE but

expect_equal(c("Male", "Female"), c("Female", "Male"))

should return FALSE

On Sep 15, 2016, at 2:45 PM, Amelia McNamara notifications@github.com wrote:

I know you are using base functions like all.equal() to do the underlying checks, but it would be nice to have a way to check levels in factor variables without getting the ordering precisely right. See https://github.com/dsscollection/factor-mgmt/blob/master/analysis/working_with_factors.Rnw#L394 for an example of what I'm talking about. In essence, I wish that I could run

expect_equivalent(c("Male", "Female"), c("Female", "Male"))

and get a TRUE.
Maybe this is something more appropriate for https://github.com/hadley/forcats ?

cc @nicholasjhorton


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Nicholas Horton
Professor of Statistics
Department of Mathematics and Statistics, Amherst College
PO Box 5000, AC #2239
Amherst, MA 01002-5000

@hadley
Copy link
Member

hadley commented Dec 15, 2016

Maybe expect_setequal() that would use setequal() under the hood?

I'm unlikely to implement this myself, but I'd be happy to review a PR.

@hadley hadley added expectation 🙀 feature a feature request or enhancement labels Dec 15, 2016
@hadley hadley added the wip work in progress label Oct 2, 2017
@hadley hadley closed this as completed in e3880d6 Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expectation 🙀 feature a feature request or enhancement wip work in progress
Projects
None yet
Development

No branches or pull requests

3 participants