You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a general concept that could be REALLY useful for this package is 'partial functions'.
Basically take an existing function and copy it, but set some fixed values for some parameters.
this is implemented in purrr::partial():
Example:
we want a version of scale_y_continuous, but impact style and for percent. It's basically the same as ggplot2::scale_y_continuous, except that some parameters are defined by us: "limits" and "labels".
this made a copy of scale_y_continuous, but some of the parameters are now fixed; this makes an impact scale:
ggplot() + scale_y_percent_impact()
see how it's used exactly like scale_y_continuous (because purrr::partial returned an almost-copy of scale_y_continuous)
because we only set some parameters, it still works to add additional ones:
Just a general concept that could be REALLY useful for this package is 'partial functions'.
Basically take an existing function and copy it, but set some fixed values for some parameters.
this is implemented in
purrr::partial()
:Example:
we want a version of scale_y_continuous, but impact style and for percent. It's basically the same as ggplot2::scale_y_continuous, except that some parameters are defined by us: "limits" and "labels".
so we can do:
this made a copy of scale_y_continuous, but some of the parameters are now fixed; this makes an impact scale:
see how it's used exactly like scale_y_continuous (because purrr::partial returned an almost-copy of scale_y_continuous)
because we only set some parameters, it still works to add additional ones:
but the following doesnt work, because "limits" is already set:
The text was updated successfully, but these errors were encountered: