~ubuntu-branches/debian/stretch/r-cran-rnexml/stretch

« back to all changes in this revision

Viewing changes to R/get_taxa.R

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2016-04-08 13:58:39 UTC
  • Revision ID: package-import@ubuntu.com-20160408135839-ilq08z8v8p414qpn
Tags: upstream-2.0.6
ImportĀ upstreamĀ versionĀ 2.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#' get_taxa
 
3
#'
 
4
#' Retrieve names of all species/otus otus (operational taxonomic units) included in the nexml 
 
5
#' @aliases get_taxa get_otu
 
6
#' @param nexml a nexml object
 
7
#' @return the list of taxa
 
8
#' @export get_taxa get_otu
 
9
#' @examples
 
10
#' comp_analysis <- system.file("examples", "comp_analysis.xml", package="RNeXML")
 
11
#' nex <- nexml_read(comp_analysis)
 
12
#' get_taxa(nex)
 
13
#' @seealso  \code{\link{get_item}}
 
14
get_taxa <- function(nexml){
 
15
  get_level(nexml, "otus/otu")
 
16
}
 
17
get_otu <- get_taxa
 
18
 
 
19
#' get_taxa_list
 
20
#' 
 
21
#' Retrieve names of all species/otus otus (operational taxonomic units) included in the nexml 
 
22
#' @aliases get_taxa_list get_otus_list
 
23
#' @param nexml a nexml object
 
24
#' @return the list of taxa
 
25
#' @export get_taxa_list get_otus_list
 
26
#' @seealso  \code{\link{get_item}}
 
27
get_taxa_list <-
 
28
          function(nexml){
 
29
            out <- lapply(nexml@otus, function(otus){
 
30
              out <- sapply(otus@otu, function(otu) otu@label)
 
31
              names(out) <- name_by_id(otus@otu)
 
32
              out
 
33
              })
 
34
            names(out) <- name_by_id(nexml@otus)
 
35
            out
 
36
          }
 
37
get_otus_list <- get_taxa_list
 
38
 
 
39