Skip to content
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

Node Name Cannot be NA #152

Closed
billdenney opened this issue Jan 8, 2021 · 1 comment · Fixed by #153 or #154
Closed

Node Name Cannot be NA #152

billdenney opened this issue Jan 8, 2021 · 1 comment · Fixed by #153 or #154

Comments

@billdenney
Copy link
Contributor

Thank you for the package!

I have just started using data.tree, and I was wanting to make a multi-rooted tree. With a quick look, it doesn't seem like multiple roots are supported (that is a reasonable design decision), so I decided to make an NA-like node. Specifically, I made a node with

data.tree::Node$new(NA_character_)

to be the fake root, and I put all the intended roots under that so that they could represent the multiple trees.

When I used FindNode() on it, an error occurred due to a missing value. That makes sense that NA names would not be supported, but I think it would help to either modify the code to support NA names or to make it an error to create an NA name.

As an aside, I also tried to make a fake root with data.tree::Node$new(NULL), and that gave an error as well.

library(data.tree)
root <- data.tree::Node$new(NA_character_)
FindNode(root, "foo")
#> Error in if (length(filterFun) == 0 || filterFun(node)) {: missing value where TRUE/FALSE needed

Created on 2021-01-08 by the reprex package (v0.3.0)

If interested, I'd be happy to try to make a PR to do one of the following:

  • Ensure that the name is a non-NA character scalar.
  • Allow the name to be NA_character_ (while ensuring that it is a character scalar).
@gluc
Copy link
Owner

gluc commented Jan 10, 2021

Hey Bill, thx for this! I think both would work for me, but I slightly prefer the first solution, i.e. "Ensure that the name is a non-NA char scalar" (one can always use an empty string "" as a workaround for a dummy node).
Yes, I would be more than thankful for a PR!

This was referenced Jan 10, 2021
@gluc gluc closed this as completed in #153 Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants