1

I need to try and extract just one tree from a MultiPhylo containing 1000 trees (in this case the multiphylo is named 'waterbirds') in it. It does not actually matter which tree it is but for example, say tree 42?

Also I am attempting to run an ancestral state reconstruction, however when trying the code:

fit <- fastAnc(tree, brainmean, vars = TRUE, CI = TRUE)

I run into the error:

Error in fastAnc(tree, brainmean, vars = TRUE, CI = TRUE): tree should be object of class "phylo"

I believe this is due to the 'tree' object not being extracted properly.

sm925
  • 2,648
  • 1
  • 16
  • 28
  • If you type `class(tree)` does it indicate it is of class `phylo` ? – steveb Mar 06 '18 at 15:33
  • It is a good idea to make a minimal reproducible question. You can check out the link on How to make a great R reproducible examples https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – steveb Mar 06 '18 at 16:43
  • Yes, the 'tree' is of class phylo, however the 'datamean' file isn't? – Sophie Kershaw Mar 08 '18 at 10:45

1 Answers1

0

You can easily do this as follows:

#extract tree 1 from multiPhylo object 'trees':

class(trees)
## "multiPhylo"

tree1 = trees[[1]]

class(tree1)
## "phylo"
enileve
  • 180
  • 1
  • 11