custom.subsets: Separating data into custom subsets.

View source: R/custom.subsets.R

custom.subsetsR Documentation

Separating data into custom subsets.

Description

Splits the data into a customized subsets list.

Usage

custom.subsets(data, group, tree = NULL, dist.data = FALSE)

Arguments

data

A matrix or a list of matrices.

group

Either a list of row numbers or names to be used as different groups, a data.frame with the same k elements as in data as rownames, a factor or a logical vector. If group is a phylo object matching data, groups are automatically generated as clades (and the tree is attached to the resulting dispRity object).

tree

NULL (default) or an optional phylo or multiPhylo object to be attached to the data.

dist.data

A logical value indicating whether to treat the data as distance data (TRUE) or not (FALSE - default).

Details

Note that every element from the input data can be assigned to multiple groups!

Author(s)

Thomas Guillerme

See Also

chrono.subsets, boot.matrix, dispRity, crown.stem.

Examples

## Generating a dummy ordinated matrix
ordinated_matrix <- matrix(data = rnorm(90), nrow = 10)

## Splitting the ordinated matrix into two groups using row numbers
custom.subsets(ordinated_matrix, list(c(1:4), c(5:10)))

## Splitting the ordinated matrix into three groups using row names
ordinated_matrix <- matrix(data = rnorm(90), nrow = 10,
     dimnames = list(letters[1:10]))
custom.subsets(ordinated_matrix,
     list("A" = c("a", "b", "c", "d"), "B" = c("e", "f", "g", "h", "i", "j"),
          "C" = c("a", "c", "d", "f", "h")))

## Splitting the ordinated matrix into four groups using a dataframe
groups <- as.data.frame(matrix(data = c(rep(1,5), rep(2,5), rep(c(1,2), 5)),
     nrow = 10, ncol = 2, dimnames = list(letters[1:10], c("g1", "g2"))))
custom.subsets(ordinated_matrix, groups)

## Splitting a matrix by clade
data(BeckLee_mat50)
data(BeckLee_tree)
custom.subsets(BeckLee_mat50, group = BeckLee_tree)



TGuillerme/dispRity documentation built on Dec. 21, 2024, 4:05 a.m.