R/print.lambdas.R

Defines functions print.lambdas

Documented in print.lambdas

#' Print rmaxent lambdas objects
#'
#' Print method for `lambdas` objects generated by [parse_lambdas()].
#'
#' @param x A `lambdas` object returned by [parse_lambdas()].
#' @param digits The minimum number of significant digits to be used.
#' @param ... Other arguments to [print.data.frame()].
#' @keywords maxent, lambdas
#' @seealso [parse_lambdas()] [project()]
#' @export
#' @details This function summarises the `data.frame` holding feature 
#'   weights in an `rmaxent` `lambdas` object. To see that information
#'   in full for `lambdas` object `x`, use `x$lambdas` or
#'   `unclass(x)`. See `str(x)` to examine the structure of an
#'   object of `lambdas` class.
print.lambdas <- function(x, digits=4, ...) {
  nonzero <- x$lambdas[x$lambdas$lambda != 0, c(
    'feature', 'lambda', 'min', 'max', 'type')]
  zero <- x$lambdas[x$lambdas$lambda == 0, c(
    'feature', 'lambda', 'min', 'max', 'type')]
  if(nrow(nonzero) > 0) {
    cat('\nFeatures with non-zero weights\n\n')
    print(nonzero, row.names=F, digits=digits, ...)
    cat('\n')
  }
  if(nrow(zero) > 0) {
    cat('\nFeatures with zero weights\n\n')
    print(zero, row.names=FALSE, digits=digits, ...)  
    cat('\n')
  }
  # meta <- t(as.data.frame(x[-1]))
  # dimnames(meta) <- list(
  #   c('Linear predictor normalizer', 'Density normalizer', 
  #     'Number of background points', 'Entropy'), ''
  # )
  # cat('\n---\n')
  # print(meta, digits=digits)
}
johnbaums/rmaxent documentation built on Feb. 16, 2020, 8:07 p.m.