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

Comments

Projects
None yet
3 participants
@AmeliaMN

AmeliaMN commented Sep 15, 2016

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

This comment has been minimized.

nicholasjhorton commented Sep 15, 2016

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

This comment has been minimized.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment