After doing some geospatial work in R, and inspired by a friend who worked on a major project involve large amounts of quantile creation for map algebra, I realized a problem. There is no good tidy way to create quantiles with the tidyverse.
For creating things such as Bivariate maps, the creation of quantiles is required to figure out which category each observation will fall under. While one can copy and paste the code to create quantiles, it would be nice to do things in a tidy fashion, along with bring in some tools to make working with geospatial data slightly easier.
Cutting Things Up
The first function itself is very simple, as seen below.
One can not only use the pipe operator to send the data that will be converted into quantiles, but the interface also allows one to create quantiles for any percentile one desires.
It also works as a way to end a group_by after one does a
count. The sky is the limit however, for what method you want to do to pipe the data in
Geospatial Quantile Analysis
The second part of this potential package is doing the same, but with geospatial data. At least for me, copying and pasting
st_join and then
group_by over and over again is not very DRY. This can be fixed however!
Instead of copying and pasting code over and over again, for example, this is possible!
Additionally, I discovered that creating a more concise way to talley, espieclly when one needs to merge the results back in for mapping is a nice side effect of the former function.
One can also pipe this into a
tidy_quantile, but with the st version existing, why use two functions when one will do all the work?
The package is on GitHub if you want to play around with it. Before I put it on CRAN however, I need to improve the documentation a bit along with ensure that edge cases are accounted for. A link to the package on GitHub below:
To install while I clean documentation up to get the package onto CRAN, use the followng package.