However, the [<-.multiPhylo function fails when a TipLabel attribute is present and no parameter is passed, i.e.
trees <- c(read.tree(text = '(a, b, c);'), read.tree(text = '(a, b, c);'))
DoSomething <- function(tree) return(tree)
# This drops the multiPhylo class
bad <- lapply(trees, DoSomething)
# Keep multiPhylo class: This works okay
trees[] <- lapply(trees, DoSomething)
# But if trees have a TipLabels attribute, we fail:
attr(trees, 'TipLabel') <- c('a', 'b', 'c')
trees[] <- lapply(trees, DoSomething)
# Error in `[<-.multiPhylo`(`*tmp*`, , value = list(list(edge = c(4L, 4L, :
# argument "..1" is missing, with no default
The syntax
myList[] <- X
typically allows entries of a list to be modified without overwriting attributes.Compare:
However, the
[<-.multiPhylo
function fails when aTipLabel
attribute is present and no parameter is passed, i.e.