Check that Node object names are compliant

check_compliant_node(node)

Arguments

node

the Node object, or a dataframe ready to be parsed by data.tree::as.Node()

Value

node if it is compliant, else an Error with the column names to fix

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
library(data.tree)
data(starwars)
starwars_tree <- starwars %>%
  mutate(pathString = paste("tree", species, homeworld, `name`, sep = "/"))

# pre as.Node() check
try(check_compliant_node(starwars_tree))
#> Error : The attributes or colnames in the provided hierarchical object use the following reserved names : 'name', 'height'. Please change those names as they will lead to unexpected tabnet behavior.

# post as.Node() check
check_compliant_node(as.Node(starwars_tree))