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

Enabling visdat to ignore minor differences #96

Open
BobMuenchen opened this issue Sep 3, 2018 · 1 comment
Open

Enabling visdat to ignore minor differences #96

BobMuenchen opened this issue Sep 3, 2018 · 1 comment
Milestone

Comments

@BobMuenchen
Copy link

BobMuenchen commented Sep 3, 2018

It would be helpful if vis_compare could have an argument to tell it to ignore minor differences such as a shifted column location, storage type, or a different sort order. The functions tidyverse::setequal or compare::compare can detect those changes and tell you the data frames are otherwise the same:

Ways to compare data frames

names(mtcars)
mtcars2 <- mtcars

Change cyl to character vector

mtcars2$cyl <-
as.character(mtcars2$cyl)

Visualize the column differences (This will show any differences)

vis_compare(mtcars, mtcars2)

Change variable order

mtcars2 <- select(mtcars2,
wt:carb, mpg:drat)

vis_compare doesn't know how to ignore this type of difference

vis_compare(mtcars, mtcars2)

Change row order by sorting

library("tidyverse")
mydata100b <- arrange(mtcars2, mpg)

#Three ways to compare

identical(mtcars, mtcars2)

all.equal(mtcars, mtcars2)

setequal figures out what happened, but doesn't report different sort order.

library("tidyverse")
setequal(mtcars, mtcars2)

The compare package reports even the sort difference

install.packages("compare")
library("compare")

This tests one column at a time

compare(mtcars, mtcars2)

This figures out all changes:

compare(mtcars, mtcars2, allowAll = TRUE)

visdat can't ignore those relatively minor changes

library("visdat")
vis_compare(mtcars, mtcars2)

@njtierney njtierney added this to the V0.7.0 milestone Sep 19, 2018
@njtierney
Copy link
Collaborator

Thank you for taking the time to write this!

The compare package looks like a great approach to this, hopefully this can make it into the next release of visdat.

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

No branches or pull requests

2 participants