R/taxa.table.R

Defines functions taxa.table

Documented in taxa.table

#' Making a Taxa Table based on the result of function TPL for Phylomatic
#' 
#' Making taxa table for software Phylomatic, as "Family/Genus/species"
#' 
#' x must be a data.frame generated by function \code{\link{TPL}}.
#' 
#' @param x A data.frame generated by function \code{\link{TPL}}
#' @param file A character string referring the name of the plain text file to
#' be generated.
#' @param substitute.sp.white.space The substitution symbol between the genus
#' and specific epithet.
#' @return Taxa table for software Phylomatic.
#' @author Jinlong Zhang \email{ jinlongzhang01@@gmail.com }
#' @seealso \code{\link{TPL}}
#' @references Webb, C. O. and M. J. Donoghue (2005). Phylomatic: tree assembly
#' for applied phylogenetics. Molecular Ecology Notes 5(1): 181-183.
#' @examples
#' 
#' 
#' sp <- c( "Ranunculus japonicus", "Anemone udensis", 
#'          "Ranunculus repens", "Ranunculus chinensis", 
#'          "Solanum nigrum", "Punica sp." ) 
#' res <- TPL(sp)
#' taxa.table(res)
#' 
#' 
#' @export taxa.table
taxa.table <-
  function(x,
           file = NULL,
           substitute.sp.white.space = "_") {
    res <-
      paste(
        x$FAMILY,
        x$POSSIBLE_GENUS,
        gsub(" ", substitute.sp.white.space, x$YOUR_SEARCH),
        sep = "/"
      )
    if (!is.null(file)) {
      writeLines(res, file)
    }
    return(res)
  }
helixcn/plantlist documentation built on Aug. 4, 2022, 1:22 p.m.