List entire taxonomic breakdown instead of queried level of hierarchy
MollicMeyer opened this issue · 9 comments
I'm not sure if this package is already capable of this option, but it's nice to to query a subgroup (or higher) and get all the levels at once.
Alltax <- function(x)
{
require(SoilTaxonomy)
levels <- c("order", "suborder", "greatgroup", "subgroup")
for(i in levels){
n <- getTaxonAtLevel(x, level = i)
print(paste0(i, " = ", n))}
}
Alltax('hapludolls')
[1] "order = mollisols"
[1] "suborder = udolls"
[1] "greatgroup = hapludolls"
[1] "subgroup = NA"
Hi Meyer,
Does this work?
getChildTaxa('Ultisols')
Hi Dylan,
Thanks for the quick response. This package works great for new students trying to enter legacy data but don't know what they're looking at.
It looks like that function lists all the possible lower taxa options from the book. My thought was if you wanted all levels from a single input, the function could return them, instead of having to specify which level you wanted aka. getTaxonAtLevel("hapludolls", level = "order')
Thanks @MollicMeyer, this is a great suggestion. I think I had intended getTaxonAtLevel()
to work at all levels at one point, but currently requires the level be specified. I will implement this change and leave this issue open for your feedback
Thank you @brownag !
Try the latest (712db07) from GitHub. I now get:
library(SoilTaxonomy)
# as before (order is default)
getTaxonAtLevel("hapludolls")
#> hapludolls
#> "mollisols"
# as before
getTaxonAtLevel("hapludolls", level = "order")
#> hapludolls
#> "mollisols"
# new simplify argument (forces data.frame result)
getTaxonAtLevel("hapludolls", level = "order", simplify = FALSE)
#> order
#> hapludolls mollisols
# always data.frame result when level has length > 1
getTaxonAtLevel("hapludolls", level = c("order", "suborder", "greatgroup", "subgroup"))
#> order suborder greatgroup subgroup
#> hapludolls mollisols udolls hapludolls <NA>
# works the same with multiple taxa (row names are inputs, colnames are levels)
getTaxonAtLevel(c("haploxerolls", "hapludolls"), level = c("order", "suborder", "greatgroup", "subgroup"))
#> order suborder greatgroup subgroup
#> haploxerolls mollisols xerolls haploxerolls <NA>
#> hapludolls mollisols udolls hapludolls <NA>
Thanks @brownag this is a nice addition.
@brownag I just installed from the git version. Seems to be a data.frame merge error:
getTaxonAtLevel(c("haploxerolls", "hapludolls"), level = c("order", "suborder", "greatgroup", "subgroup"))
Error in fix.by(by.y, y) : 'by' must specify a uniquely valid column
@MollicMeyer Hmm... make sure you've successfully installed the new version from GH. Can you try to restart your session and make sure no remnants from past sessions get reloaded? I am unable to reproduce that error--the same command is now used in the unit tests. It seems to pass on my computer and on the different test platforms as follows...
library(SoilTaxonomy)
getTaxonAtLevel(c("haploxerolls", "hapludolls"), level = c("order", "suborder", "greatgroup", "subgroup"))
#> order suborder greatgroup subgroup
#> haploxerolls mollisols xerolls haploxerolls <NA>
#> hapludolls mollisols udolls hapludolls <NA>
@brownag Thanks for double checking. Not sure what's wrong with this machine, but the function performs properly on another device.