[R] allequal diff

sibyiie@stoeckii m@iii@g oii gmx@ch sibyiie@stoeckii m@iii@g oii gmx@ch
Thu Aug 15 15:14:06 CEST 2024


Dear community



Similar to the example of the rdocumentation, my idea is to use all.equal
and to print the difference.

https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/all.equal



> d45 <- pi*(1/4 + 1:10)

> stopifnot(

+     all.equal(tan(d45), rep(1, 10)))          # TRUE, but

> all      (tan(d45) == rep(1, 10))         # FALSE, since not exactly

[1] FALSE

> all.equal(tan(d45), rep(1, 10), tolerance = 0)  # to see difference

[1] "Mean relative difference: 1.29526e-15"

>



Unfortunately, I just get "FALSE" not the difference.

> r2_resampled <- resample(r2, r1)

> compareRaster(r1, r2_resampled)

[1] TRUE

> # Compare rasters

> result <- all.equal(r1, r2_resampled)

Warning message:

In compareRaster(target, current, ..., values = values, stopiffalse =
stopiffalse,  :

  not all objects have the same values

> print(result)

[1] FALSE

>



Kind regards

Sibylle


	[[alternative HTML version deleted]]



More information about the R-help mailing list