Processes a vector of txonomy strings and returns a vector with the specified level
get_tax_level(Tax, level = 4, sepchar = ";")
Tax | A data.frame with a column named 'Taxonomy' which is a character vector with taxonomy strings. |
---|---|
level | The level to return |
sepchar | The separator of each level in the taxonomy string |
A vector of taxonomy strings truncated at the specified level
It splits each taxonomy string according to separator and returns the specified level. If there are fewer levels than the specified number, it returns the value 'unclassified'
tax <- data.frame(ID = letters[1:4], Taxonomy = c('a;b;c;d','a;b','A;B;C','A;B;C;D')) get_tax_level(tax, level = 2)#> [1] "a;b" "a;b" "A;B" "A;B"