R Under development (unstable) (2024-01-28 r85838 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(phylobase) > library(ape) Attaching package: 'ape' The following object is masked from 'package:phylobase': edges > tree.phylo <- read.tree(text="(((A,B)C,D),E);") #only one node is labelled > tree <- as(tree.phylo, "phylo4") > > tree.phylo2 <- read.tree(text="(((A,B)C,D)F,E)G;") # all nodes labelled > tree2 <- as(tree.phylo2, "phylo4") > > tip.data <- data.frame(size=c(1, 2, 3, 4)) > rownames(tip.data) <- c("A", "B", "E", "D") > > treed <- phylo4d(tree, tip.data) > dat2 <- data.frame(size=c(0,1,2), row.names=c("G", "F", "C")) > > try(phylo4d(tree, node.data=dat2), silent = TRUE) # error, cannot match data because no node labels on tree > phylo4d(tree2, node.data=dat2) -> treed2 # OK tree labelled; has node data, no tip data > > plot(treed2) # works with a warning about no tip data to plot Warning message: In treePlot(x, ...) : tree has no tip data to plot > tipData(treed2, empty.columns=FALSE) #returns empty 4-row data.frame data frame with 0 columns and 4 rows > > phylo4d(tree2, tip.data=tip.data, node.data=dat2) -> treed3 #node+tip data > > plot(treed3) # works > tipData(treed3) #works, but returns tips only size A 1 B 2 D 4 E 3 > tdata(treed3, "all") size A 1 B 2 D 4 E 3 G 0 F 1 C 2 > > print(tree) label node ancestor edge.length node.type 1 A 1 7 NA tip 2 B 2 7 NA tip 3 D 3 6 NA tip 4 E 4 5 NA tip 5 5 0 NA root 6 6 5 NA internal 7 C 7 6 NA internal > print(treed) label node ancestor edge.length node.type size 1 A 1 7 NA tip 1 2 B 2 7 NA tip 2 3 D 3 6 NA tip 4 4 E 4 5 NA tip 3 5 5 0 NA root NA 6 6 5 NA internal NA 7 C 7 6 NA internal NA > > > proc.time() user system elapsed 1.98 0.45 2.35