Skip to content

Error in FUN(X[[i]], ...) in function as.phylo.Node if internal node contains parenthesis #161

@danlooo

Description

@danlooo

Hello,

this error will be thrown using function data.tree::as.phylo.Node if a parenthesis character was part of an internal node label: Error in FUN(X[[i]], ...): attempt to set index 2/2 in SET_STRING_ELT.

library(tidyverse)
library(data.tree)
library(ape)

tree <-
  tibble(pathString = c("foo/bar (a)", "foo/bar(a)/bar (b)")) %>%
  as.Node(pathDelimiter = "/")
tree
#>         levelName
#> 1 foo            
#> 2  ¦--bar (a)    
#> 3  °--bar(a)     
#> 4      °--bar (b)

tree %>% as.phylo.Node()
#> Error in FUN(X[[i]], ...): attempt to set index 2/2 in SET_STRING_ELT

R.version$version.string
#> [1] "R version 4.1.2 (2021-11-01)"
packageVersion("data.tree")
#> [1] '1.0.0'

Created on 2022-02-01 by the reprex package (v2.0.1)

Errror reproduced in a Docker container with image rocker/tidyverse:4.1.2.
The code runs fine but with modifying node labels if ( is only present in tip labels

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions