R/summary_taxonsampling.R

Defines functions summary.taxonsampling

Documented in summary.taxonsampling

#' summary.taxonsampling
#'
#' S3 method for summarizing _taxonsampling_ objects output by [run_TS()]).
#'
#' @param object list object of class _taxonsampling_
#'                     (generated by [run_TS()])
#' @param ... other parameters to be passed down to specific
#'            summary functions (currently unused)
#'
#' @return Nothing (called for side effects)
#'
#' @method summary taxonsampling
#'
#' @export
#'
summary.taxonsampling <- function(object, ...)
{
  if("ts.params" %in% names(object) && is.list(object$ts.params)){
    message(rep("-", 30))
    message("Processed 'taxonsampling' object returned by run_TS()\nwith input parameters:")
    for (i in seq_along(names(object$ts.params))){
      if(is.null(object$ts.params[[i]])) object$ts.params[[i]] <- "NULL"
      message(names(object$ts.params)[i], ": ", paste(object$ts.params[[i]], collapse = ","))
    }
    message(rep("-", 30))
  }

  if("ts.params" %in% names(object) && is.list(object$ts.params)){
    message("Element 'ts.params':\tlist with ",
            length(object$ts.params), " elements")
  }

  if("nodes" %in% names(object) && is.data.frame(object$nodes)){
    message("Element 'nodes':\tdata frame [",
            paste(names(object$nodes), collapse = ", "),
            "]; ", nrow(object$nodes), " rows")
  }

  if("ids_df" %in% names(object) && is.data.frame(object$ids_df)){
    message("Element 'ids_df':\tdata frame [",
            paste(names(object$ids_df), collapse = ", "),
            "]; ", nrow(object$ids_df), " rows")
  }

  if("spp_df" %in% names(object) && is.data.frame(object$spp_df)){
    message("Element 'spp_df':\tdata frame [",
            paste(names(object$spp_df), collapse = ", "),
            "]; ", nrow(object$spp_df), " rows")
  }

  if("countIDs" %in% names(object) && is.vector(object$countIDs)){
    message("Element 'countIDs':\tvector with ",
            length(object$countIDs), " elements")
  }

  if("outputIDs" %in% names(object) && is.vector(object$outputIDs)){
    message("Element 'outputIDs':\tvector with ",
            length(object$outputIDs), " elements")
  }

  if("outputSeqs" %in% names(object) && is.list(object$outputSeqs)){
    message("Element 'outputSeqs':\tlist with ",
            length(object$outputSeqs), " elements")
  }
  message(rep("-", 30))

  invisible(NULL)
}
fcampelo/TaxonSampling documentation built on Jan. 29, 2022, 7:11 a.m.