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

Martin Ivanov tramni at abv.bg
Sun Dec 18 12:35:37 CET 2016


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 safely
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,
Martin



More information about the R-help mailing list