Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ExtractTaxa

Extract taxa from a matrix block


Description

Extract leaf labels and character states from a Nexus-formatted matrix.

Usage

ExtractTaxa(
  matrixLines,
  character_num = NULL,
  session = NULL,
  continuous = FALSE
)

NexusTokens(tokens, character_num = NULL, session = NULL)

Arguments

matrixLines

Character vector containing lines of a file that include a phylogenetic matrix. See ReadCharacters() for expected format.

character_num

Index of character(s) to return. NULL, the default, returns all characters.

session

(Optional) A Shiny session with a numericInput named character_num whose maximum should be updated.

continuous

Logical specifying whether characters are continuous. Treated as discrete if FALSE.

tokens

Vector of character strings corresponding to phylogenetic tokens.

Value

ExtractTaxa() returns a matrix with n rows, each named for the relevant taxon, and c columns, each corresponding to the respective character specified in character_num.

NexusTokens() returns a character vector in which each entry corresponds to the states of a phylogenetic character, or a list containing an error message if input is invalid.

Examples

fileName <- paste0(system.file(package='TreeTools'),
                   '/extdata/input/dataset.nex')
matrixLines <- readLines(fileName)[6:11]
ExtractTaxa(matrixLines)

NexusTokens('01[01]-?')

TreeTools

Create, Modify and Analyse Phylogenetic Trees

v1.4.4
GPL (>= 3)
Authors
Martin R. Smith [aut, cre, cph] (<https://orcid.org/0000-0001-5660-1727>), Emmanuel Paradis [cph] (<https://orcid.org/0000-0003-3092-2199>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.