[R] setAs: does it overwrite existing coerce methods?

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Sun Dec 18 20:14:13 CET 2016

You probably should have asked this on R-sig-geo. Technically, recent versions of R require that packages import dependencies, so your new function should not be called from within any packages. 

I am not an expert with the sp package but I would be concerned that if you passed your modified objects to existing package functions that they might not work if they assume the data are sorted the other way. Are you sure you cannot re-extract the data at the point when you need it sorted the other way? 
Sent from my phone. Please excuse my brevity.

On December 18, 2016 3:35:37 AM PST, Martin Ivanov <tramni at abv.bg> wrote:
>Dear R users,
>I am working a lot with spatial objects from the package sp. I need to
>write my own method for converting a SpatialGrid
>to a SpatialPoints object, because the default method as("SpatialGrid",
>"SpatialPoints") returns a SpatialPoints object with
>decreasing latitudes. If I write my own method (that creates a
>SpatialPoints object with both longitudes and latitudes increasing)
>using setAs, will it overwrite the default method provided by the sp
>packages? Will this result in breaking all other methods in sp
>that use as()? If the sp methods always call the as() method from sp,
>this should not be the case. But if they happen to call the method I 
>am going to define instead of the one they expect, they might get
>broken. So, what is your opinion about this is? Is there a way to
>define a coerce method with setAs that only the code written by me
>uses, so  that no other code coming from packages is broken?
>Thank you very much!
>Best regards,
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list