[R] allequal diff

sibyiie@stoeckii m@iii@g oii gmx@ch sibyiie@stoeckii m@iii@g oii gmx@ch
Fri Aug 16 11:03:44 CEST 2024


Here my idea including the error:

 

> m1=r1[r1="NA",]

> m2=r2_resampled[r2_resampled="NA",]

> 

> 

> all.equal(getValues(r1)[!m1], getValues(r2_resampled)[!m2])

[1] "Numeric: lengths (80706867, 65806339) differ"

 

-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of SIBYLLE STÖCKLI via R-help
Sent: Friday, August 16, 2024 10:36 AM
To: 'Ivan Krylov' <ikrylov using disroot.org>; 'SIBYLLE STÖCKLI via R-help' <r-help using r-project.org>
Subject: Re: [R] allequal diff

 

Many thanks Ivan

 

 

Use is.na() on getValues() outputs, combine the two masks using the | operator to get a mask of values that are missing in either raster, then negate the mask to choose the non-missing values:

 

all.equal(getValues(r1)[!mask], getValues(r2)[!mask])

 

--> what do you mean by use is.na() in getValues(). So I need to call getValues a second time? I suppose you mean to first prepare a mask using is.na without getValues and then in the second step your code?

 

Kind regards

Sibylle

 

-----Original Message-----

From: Ivan Krylov < <mailto:ikrylov using disroot.org> ikrylov using disroot.org>

Sent: Friday, August 16, 2024 9:28 AM

To: SIBYLLE STÖCKLI via R-help < <mailto:r-help using r-project.org> r-help using r-project.org>

Cc:  <mailto:sibylle.stoeckli using gmx.ch> sibylle.stoeckli using gmx.ch

Subject: Re: [R] allequal diff

 

В Fri, 16 Aug 2024 07:19:38 +0200

SIBYLLE STÖCKLI via R-help < <mailto:r-help using r-project.org> r-help using r-project.org> пишет:

 

> Is it possible to consider na.rm=TRUE?

 

> > all.equal(getValues(r1), getValues(r2_resampled), tolerance = 0)

> 

> [1] "'is.NA' value mismatch: 9544032 in current 66532795 in target"

 

Use is.na() on getValues() outputs, combine the two masks using the | operator to get a mask of values that are missing in either raster, then negate the mask to choose the non-missing values:

 

all.equal(getValues(r1)[!mask], getValues(r2)[!mask])

 

--

Best regards,

Ivan

 

______________________________________________

 <mailto:R-help using r-project.org> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see  <https://stat.ethz.ch/mailman/listinfo/r-help> https://stat.ethz.ch/mailman/listinfo/r-help

PLEASE do read the posting guide  <http://www.R-project.org/posting-guide.html> http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


	[[alternative HTML version deleted]]



More information about the R-help mailing list