alexsanjoseph / compareDF

R Tool to compare two data.frames
Other
93 stars 17 forks source link

rounding doubles to 2 decimal places - what's the purpose? #18

Closed grahamgill closed 5 years ago

grahamgill commented 5 years ago

compareDF is very useful, thanks.

What's the purpose of the r2two() function, and rounding doubles to 2 decimal places? Shouldn't values be left unrounded and the tolerance setting of compare_df() used to pick what counts as a difference, no matter the scale?

I want to use the data in compare_df(...)$comparison_df for further computation, not just display or summarising changes. I need the reported values to be what they were originally.

I'm working around this at the moment by multiplying doubles columns by 10^n, with whatever n is relevant to my use case, before calling compare_df(), then converting comparison_df back.

alexsanjoseph commented 5 years ago

Shouldn't values be left unrounded and the tolerance setting of compare_df() used to pick what counts as a difference, no matter the scale

That's a very smart idea - Hadn't thought of it. Will make an update soon regarding this.

alexsanjoseph commented 5 years ago

I didn't implement rounding as inferred from tolerance because tolerance could be of two types and it gets complicated. I have added a simpler (albeit less elegant) approach of adding a parameter.

@grahamgill - I've pushed a new commit. Can you verify if the new parameter solves the problem? You'll have to install this dev version directly from github using devtools::install_github()