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

Handle NAs #5

Closed eusebe closed 9 years ago

eusebe commented 9 years ago

Hi,

Thank you for this very usefull package!

I tried the following code:

> y <- iris[1:3,]
> x <- y
> x$Sepal.Width[2] <- NA
> y
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
> x
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9          NA          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
> patch <- diff_data(y, x)
> render_diff(patch)
@@Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpecies
5.13.51.40.2setosa
->4.93->1.41.4->0.20.2->setosasetosa->NULL
4.73.21.30.2setosa

Is it expected?

Best, David

edwindj commented 9 years ago

Thanks! You just uncovered a bug :-).

edwindj commented 9 years ago

Working on it: It has to do with the jsonlite communication:

jsonlite::toJSON(data.frame(a=1,b=NA))

results in

[{a: 1}]
jeroen commented 9 years ago

Perhaps you can use 'na=null' or na=string in tojson On Feb 23, 2015 6:54 AM, "Edwin de Jonge" notifications@github.com wrote:

Working on it: It has to do with the jsonlite communication:

jsonlite::toJSON(data.frame(a=1,b=NA))

results in

[{a: 1}]

— Reply to this email directly or view it on GitHub https://github.com/edwindj/daff/issues/5#issuecomment-75554927.

edwindj commented 9 years ago

@jeroenooms Thanks! I solved it differently: since daff.js uses a matrix internally I used jsonlite::toJSON(..., dataframe='values').

eusebe commented 9 years ago

Quick and clean, thanks! David