Replace sf_rescale01_x()
with scales::rescale()
#5475
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a personal pet peeve of mine.
First, let me start by apologising for the tone of this PR.
The two functions in the title are in principle doing the same operation, but
scales::rescale()
supports more data types than just numeric.Every time I look at
coord_sf()
's code, I have to remind myself that they're really doing the same thing despite being named differently. If this PR gets merged, this saves me 5 seconds of my life every time I'm dealing withcoord_sf()
.Ulterior motive is also that I might want to feed not-bare-numeric data to
coord_sf()
at some point with a customrescale
method.Typical coords use the
Scale$rescaler()
method. However, as thegeometry
column cannot be transformed byrescale()
, we should not use theScale$rescaler()
method. If we did, annotations such as graticules and axis positions can become out of sync when a user has somehow engineered a non-standardrescaler
in a position scale.