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

Extend `parse_family()` to work with taxa above family #46

Closed brownag closed 8 months ago

brownag commented 8 months ago

Now gives more complete results when parse_family() is called on a heterogeneous vector of taxonomic class names, some of which may be taxa above family.

suppressPackageStartupMessages(library(soilDB))
library(SoilTaxonomy)

x <- data.frame(
  taxonname = c("Alberti", "Aquents", "Lithic Xeric Torriorthents", "Stagy Family", "Haplodurids"),
  taxonkind = c("series", "taxon above family", "taxon above family", "family", "taxon above family"),
  taxclname = c(
    "Clayey, smectitic, thermic, shallow Vertic Rhodoxeralfs", # Full family name
    "Aquents",                                                 # Taxon above subgroup
    "Lithic Xeric Torriorthents",                              # Subgroup
    "Coarse-loamy, mixed, mesic Duric Haploxerolls",           # Fill family name (missing activity)
    "Mixed, superactive, thermic Haplodurids"                  # Taxon above family (family class + great group)
  ))
parse_family(x$taxclname)
#>                                                    family
#> 1 Clayey, smectitic, thermic, shallow Vertic Rhodoxeralfs
#> 2                                                    <NA>
#> 3                                                    <NA>
#> 4           Coarse-loamy, mixed, mesic Duric Haploxerolls
#> 5                 Mixed, superactive, thermic Haplodurids
#>                                                 taxclname
#> 1 Clayey, smectitic, thermic, shallow Vertic Rhodoxeralfs
#> 2                                                 Aquents
#> 3                              Lithic Xeric Torriorthents
#> 4           Coarse-loamy, mixed, mesic Duric Haploxerolls
#> 5                 Mixed, superactive, thermic Haplodurids
#>                    taxonname subgroup_code code
#> 1        vertic rhodoxeralfs          JDEB JDEB
#> 2                    aquents          <NA>   LB
#> 3 lithic xeric torriorthents          LECB LECB
#> 4         duric haploxerolls          IFFZ IFFZ
#> 5                haplodurids          <NA>  GCC
#>                          class_string classes_split  taxpartsize taxpartsizemod
#> 1 Clayey, smectitic, thermic, shallow  Clayey, ....       clayey             NA
#> 2                                                           <NA>             NA
#> 3                                                           <NA>             NA
#> 4          Coarse-loamy, mixed, mesic  Coarse-l.... coarse-loamy             NA
#> 5         Mixed, superactive, thermic  Mixed, s....         <NA>             NA
#>   taxminalogy  taxceactcl taxreaction taxtempcl taxfamhahatmatcl taxfamother
#> 1   smectitic        <NA>          NA   thermic               NA     shallow
#> 2        <NA>        <NA>          NA      <NA>               NA        <NA>
#> 3        <NA>        <NA>          NA      <NA>               NA        <NA>
#> 4       mixed        <NA>          NA     mesic               NA        <NA>
#> 5       mixed superactive          NA   thermic               NA        <NA>
#>                    taxsubgrp   taxgrtgroup taxsuborder  taxorder
#> 1        Vertic Rhodoxeralfs  Rhodoxeralfs     Xeralfs  Alfisols
#> 2                       <NA>          <NA>     Aquents  Entisols
#> 3 Lithic Xeric Torriorthents Torriorthents    Orthents  Entisols
#> 4         Duric Haploxerolls  Haploxerolls     Xerolls Mollisols
#> 5                       <NA>   Haplodurids      Durids Aridisols