-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
data.tree wrapper functions #43
Comments
Good ideas. I remember struggling with trying to balance intuitive vs. compact displays of these data. The hierarchy is "wide" and "shallow" so many of the standards methods for displaying trees break down. It might be best to display each soil order in its own tree. Added some slightly updated examples to I wonder if the author of the data.tree package would be open to alternative tree listing styles. |
Since I've had such good luck with the maintainer of data.tree in the past, I tried posting some questions / ideas over there: |
Cool, I have some ideas on that that won't require changes to data.tree. To remove line numbers I am thinking I can make a subclass of {data.tree} taxonTree <- function(...) {
# ...
attr(n, "class") <- c("SoilTaxonNode", attr(n, "class"))
invisible(n)
}
#' @export
print.SoilTaxonNode <- function(x, ...) {
# print the tree without rownames
res <- as.data.frame(x)
cat(res$levelName, sep = "\n")
} |
* Add `taxonTree()` #43 * taxonTree: cleanup and add customizable `level` argument * Add custom print method for data.tree subclass `SoilTaxonNode` #43 * verbose = FALSE default, no args to default print() method, allow replacement of all markup chars * Add support for custom (e.g. unicode) tree markup for printing * cleanup+test * skip test when data.tree not available
Getting a little closer to the output from taxonTree(c('palexeralfs', 'rhodoxeralfs'), special.chars = c("\u2502", "\u2514", "\u2500 ")) However, we can't get the exact output without using an additional character (tree.R):
Not sure, but this might require changes in data.tree. |
I don't think this particular request requires changes to data.tree. Just a minor change to the print method. Now this works well, thanks for the suggestion to emulate fs::dir_tree(), I originally was not really going for a direct clone library(SoilTaxonomy)
taxonTree(c('palexeralfs', 'rhodoxeralfs'), special.chars = c("\u251c","\u2502", "\u2514", "\u2500 "))
#> Loading required namespace: data.tree
#> Soil Taxonomy
#> └─ alfisols
#> └─ xeralfs
#> ├─ rhodoxeralfs
#> │ ├─ lithic rhodoxeralfs
#> │ ├─ vertic rhodoxeralfs
#> │ ├─ petrocalcic rhodoxeralfs
#> │ ├─ calcic rhodoxeralfs
#> │ ├─ inceptic rhodoxeralfs
#> │ └─ typic rhodoxeralfs
#> └─ palexeralfs
#> ├─ vertic palexeralfs
#> ├─ aquandic palexeralfs
#> ├─ andic palexeralfs
#> ├─ vitrandic palexeralfs
#> ├─ fragiaquic palexeralfs
#> ├─ aquic palexeralfs
#> ├─ petrocalcic palexeralfs
#> ├─ lamellic palexeralfs
#> ├─ psammentic palexeralfs
#> ├─ arenic palexeralfs
#> ├─ natric palexeralfs
#> ├─ fragic palexeralfs
#> ├─ calcic palexeralfs
#> ├─ plinthic palexeralfs
#> ├─ ultic palexeralfs
#> ├─ haplic palexeralfs
#> ├─ mollic palexeralfs
#> └─ typic palexeralfs |
Very cool, thanks. I kind of like this incantation: taxonTree(c('xerorthents', 'rhodoxeralfs', 'endoaqualfs'), special.chars = c("\u251c","\u2502", "\u2570", "\u2500 ")) |
It might be nice to pick a unicode output we like as the default. I was thinking ASCII might be a better default, but the package does use UTF-8 encoding per the DESCRIPTION, so there's no reason we couldn't have that. I like the above suggestion To finish up this issue I will also need to abstract out the contents of the |
I've noticed it's not super easy to get the trees put back out in a clean text-based format and that it would be good to extend on @dylanbeaudette old examples that were in the readme.
Here is a quick sample (modified version of second old example) based on 13th edition keys and an order->subgroup path string.
Ideas for output:
The text was updated successfully, but these errors were encountered: