edwindj / daff

Diff, patch and merge for data.frames, see http://paulfitz.github.io/daff/
https://edwindj.github.io/daff/
Other
153 stars 18 forks source link

inconsistent behavior when replacing values with NA #18

Closed markvanderloo closed 7 years ago

markvanderloo commented 7 years ago

Hey there,

when I replace three values in the iris dataset with NA and daff it, this is translated into a patch with two value replacements and one row replacement.

> iris2 <- iris
> iris2[1:3,1] <- NA
> diff_data(iris, iris2)
Daff Comparison: ‘iris’ vs. ‘iris2’ 
  First 6 and last 6 patch lines:
    @@ Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   ->      5.1->NA         3.5          1.4         0.2  setosa
2   ->      4.9->NA           3          1.4         0.2  setosa
3  +++           NA         3.2          1.3         0.2  setosa
4  ---          4.7         3.2          1.3         0.2  setosa
5               4.6         3.1          1.5         0.2  setosa
6  ...          ...         ...          ...         ...     ...
7  ...          ...         ...          ...         ...     ...
8   ->      5.1->NA         3.5          1.4         0.2  setosa
9   ->      4.9->NA           3          1.4         0.2  setosa
10 +++           NA         3.2          1.3         0.2  setosa
11 ---          4.7         3.2          1.3         0.2  setosa
12              4.6         3.1          1.5         0.2  setosa
13 ...          ...         ...          ...         ...     ...

I'd expect the same patch notation for the three cases, but I could be missing something.

edwindj commented 7 years ago

In the latest version I get this:

> iris2 <- iris
> iris2[1:3,1] <- NA
> diff_data(iris, iris2)
Daff Comparison: ‘iris’ vs. ‘iris2’ 
   Sepal.Length Sepal.Width Petal.Length ...
-> 5.1->NA      3.5         1.4          ...
-> 4.9->NA      3           1.4          ...
-> 4.7->NA      3.2         1.3          ...

so seems solved