]> git.donarmstrong.com Git - ape.git/blob - man/multiphylo.Rd
new operators for "multiPhylo" + fixed small bug in bind.tree()
[ape.git] / man / multiphylo.Rd
1 \name{multiphylo}
2 \alias{multiphylo}
3 \alias{[.multiPhylo}
4 \alias{[[.multiPhylo}
5 \alias{$.multiPhylo}
6 \alias{[<-.multiPhylo}
7 \alias{[[<-.multiPhylo}
8 \alias{$<-.multiPhylo}
9 \title{Manipulating Lists of Trees}
10 \description{
11   These are extraction and replacement operators for lists of trees
12   stored in the class \code{"multiPhylo"}.
13 }
14 \usage{
15 \method{[}{multiPhylo}(x, i)
16 \method{[[}{multiPhylo}(x, i)
17 \method{$}{multiPhylo}(x, name)
18 \method{[}{multiPhylo}(x, ...) <- value
19 \method{[[}{multiPhylo}(x, ...) <- value
20 \method{$}{multiPhylo}(x, ...) <- value
21 }
22 \arguments{
23   \item{x, value}{an object of class \code{"phylo"} or \code{"multiPhylo"}.}
24   \item{i}{index(ices) of the tree(s) to select from a list; this may be a
25     vector of integers, logicals, or names.}
26   \item{name}{a character string specifying the tree to be extracted.}
27   \item{\dots}{index(ices) of the tree(s) to replace; this may be a
28     vector of integers, logicals, or names.}
29 }
30 \details{
31   The subsetting operator \code{[} keeps the class correctly
32   (\code{"multiPhylo"}).
33
34 The replacement operators check the labels of \code{value} if \code{x}
35 has a single vector of tip labels for all trees (see examples).
36 }
37 \value{
38   An object of class \code{"phylo"} (\code{[[}, \code{$}) or of class
39   \code{"multiPhylo"} (\code{[} and the replacement operators).
40 }
41 \author{Emmanuel Paradis}
42 \seealso{
43   \code{\link{summary.phylo}}, \code{\link{c.phylo}}
44 }
45 \examples{
46 x <- rmtree(10, 20)
47 names(x) <- paste("tree", 1:10, sep = "")
48 x[1:5]
49 x[1] # subsetting
50 x[[1]] # extraction
51 x$tree1 # same than above
52 x[[1]] <- rtree(20)
53
54 y <- .compressTipLabel(x)
55 ## up to here 'x' and 'y' have exactly the same information
56 ## but 'y' has a unique vector of tip labels for all the trees
57 x[[1]] <- rtree(10) # no error
58 try(y[[1]] <- rtree(10)) # error
59
60 try(x[1] <- rtree(20)) # error
61 ## use instead one of the two:
62 x[1] <- list(rtree(20))
63 x[1] <- c(rtree(20))
64
65 x[1:5] <- rmtree(5, 20) # replacement
66 x[11:20] <- rmtree(10, 20) # elongation
67 x # 20 trees
68 }
69 \keyword{manip}