ncss-tech / SoilTaxonomy

A System of Soil Classification for Making and Interpreting Soil Surveys
https://ncss-tech.github.io/SoilTaxonomy/
GNU General Public License v3.0
14 stars 2 forks source link

Add "higher taxa codes" lookup table and related functions #13

Closed brownag closed 3 years ago

brownag commented 3 years ago

For doing the logical ordering like I do in the KST shiny apps

Adds four five new methods and a dataset/lookup table.

The first two methods emulate the internal logic of the two shiny apps I created (KSTLookup, KSTPreceding).

The next two methods facilitate mapping between taxon names and their codes / logical order, based on the code:taxon lookup table used for the drop down boxes in both of the apps. The lookup table is defined in a new dataset called ST_higher_taxa_codes_12th.

And the "relative position" is an application of the above -- the position of a taxon is [number of preceding Key steps] + 1, or NA if it does not exist in the lookup table.

remotes::install_github("ncss-tech/SoilTaxonomy/R_pkg@andrew")

library(SoilTaxonomy)
data(ST_higher_taxa_codes_12th)

plot(density(SoilTaxonomy::relative_taxon_code_position(ST_higher_taxa_codes_12th$code)))

image

I wanted the function names to be descriptive of what they did -- so I named as above to be clear.

I recognize that most of the existing methods in this package use camelCase or similar. Would be fine to change these as needed.

brownag commented 3 years ago

Added another method relative_taxon_code_position to determine Relative Position of Taxon within Existing Keys. The relative position of a taxon is [number of preceding Key steps] + 1, or NA if it does not exist in the lookup table.

dylanbeaudette commented 3 years ago

This is great, a nice improvement to the relatively simple tables / lists currently in this package. Thanks for adding this. I'll do some testing after it is merged. Thanks for adding it!