addData-methods: Adding data to a phylo4 or a phylo4d object

addDataR Documentation

Adding data to a phylo4 or a phylo4d object

Description

addData adds data to a phylo4 (converting it in a phylo4d object) or to a phylo4d object

Usage

addData(x, ...)

## S4 method for signature 'phylo4d'
addData(
  x,
  tip.data = NULL,
  node.data = NULL,
  all.data = NULL,
  merge.data = TRUE,
  pos = c("after", "before"),
  ...
)

## S4 method for signature 'phylo4'
addData(
  x,
  tip.data = NULL,
  node.data = NULL,
  all.data = NULL,
  merge.data = TRUE,
  pos = c("after", "before"),
  ...
)

Arguments

x

a phylo4 or a phylo4d object

...

additional arguments to control how matching between data and tree (see Details section of phylo4d-methods for more details).

tip.data

a data frame (or object to be coerced to one) containing only tip data

node.data

a data frame (or object to be coerced to one) containing only node data

all.data

a data frame (or object to be coerced to one) containing both tip and node data

merge.data

if both tip.data and node.data are provided, it determines whether columns with common names will be merged together (default TRUE). If FALSE, columns with common names will be preserved separately, with ".tip" and ".node" appended to the names. This argument has no effect if tip.data and node.data have no column names in common.

pos

should the new data provided be bound before or after the pre-existing data?

Details

Rules for matching data to tree nodes are identical to those used by the phylo4d-methods constructor.

If any column names in the original data are the same as columns in the new data, ".old" is appended to the former column names and ".new" is appended to the new column names.

The option pos is ignored (silently) if x is a phylo4 object. It is provided for compatibility reasons.

Value

addData returns a phylo4d object.

Author(s)

Francois Michonneau

See Also

tdata for extracting or updating data and phylo4d-methods constructor.

Examples

  data(geospiza)
  nDt <- data.frame(a=rnorm(nNodes(geospiza)), b=1:nNodes(geospiza),
                    row.names=nodeId(geospiza, "internal"))
  t1 <- addData(geospiza, node.data=nDt)

phylobase documentation built on May 29, 2024, 11:24 a.m.