In R, you often see plot()
being used with very different kinds of data with very different default outcomes. plot()
recognizes which object it is been given and uses the proper function according to this object.
In the example below plot()
actually refers to ape::plot.phylo()
.
library(ape)
tree.owls <-
read.tree(text =
"(((Strix_aluco:4.2,Asio_otus:4.2):3.1, Athene_noctua:7.3):6.3,Tyto_alba:13.5);")
plot(tree.owls)
Question is: how do you know that in this case plot()
refers to plot.phylo()
? More generally, ss there a way to find out that would apply to any object being plotted (vector, df, list, S3, S4, etc.)?