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

replace `ST` with updated version sorted by order in KST #35

Closed dylanbeaudette closed 1 year ago

dylanbeaudette commented 2 years ago

See misc/ST_logic.rda, thanks to Marc Olds (UCD) for this suggestion. This would have an added benefit of setting reasonable factor levels based on the "order in which taxa key out" vs. alphabetical.

dylanbeaudette commented 2 years ago

One such use case: ordering in sharpshootR::SoilTaxonomyDendrogram() based on distance matrix from ordinal vs. nominal data.

brownag commented 2 years ago

I think this would be a good time to set up the package to build all of the datasets from a data-raw folder. I don't see any issues with replacing ST with this reordered version. It does not break tests, but would be a breaking change I think warranting a bump to 0.2.0

Here is some code for validating against other datasets in the package:

library(SoilTaxonomy)
load("./misc/ST-data/ST_logic.rda")
data("ST")
x <- data.frame(
  order = getTaxonAtLevel(ST$subgroup, level = 'order'),
  suborder = getTaxonAtLevel(ST$subgroup, level = 'suborder'),
  greatgroup = getTaxonAtLevel(ST$subgroup, level = 'greatgroup'),
  subgroup = ST$subgroup,
  code = taxon_to_taxon_code(ST$subgroup)
)
x <- x[order(x$code),]
head(x)
#>                      order suborder greatgroup          subgroup code
#> lithic folistels  gelisols  histels  folistels  lithic folistels AAAA
#> glacic folistels  gelisols  histels  folistels  glacic folistels AAAB
#> typic folistels   gelisols  histels  folistels   typic folistels AAAC
#> hemic glacistels  gelisols  histels glacistels  hemic glacistels AABA
#> sapric glacistels gelisols  histels glacistels sapric glacistels AABB
#> typic glacistels  gelisols  histels glacistels  typic glacistels AABC
all(x$subgroup == ST_logic$subgroup)
#> [1] TRUE
dylanbeaudette commented 2 years ago

Good call--and I agree 100%, we have to be able to re-generate all of this from canonical sources. The only thing I wasn't sure about re-generating had to do with creating the ST object from NASIS domains. That is where it originally came from, but required a tiny but of manual "fixing". Lets sort this out at your convenience. A lot going on right now.

brownag commented 1 year ago

Closing this as the ordering was implemented in the ST_unique_list object, not ST