diff --git a/DESCRIPTION b/DESCRIPTION index 1500851..3827240 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,7 +16,7 @@ Description: A simple way of fitting detection functions to distance sampling Horvitz-Thompson-like estimator) if survey area information is provided. See Miller et al. (2019) for more information on methods and for example analyses. -Version: 2.0.0.9006 +Version: 2.0.0.9007 URL: https://github.com/DistanceDevelopment/Distance/ BugReports: https://github.com/DistanceDevelopment/Distance/issues Language: en-GB diff --git a/NEWS.md b/NEWS.md index eb66c9c..8f01c91 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * Fixes bug when including a uniform with no adjustment terms in the summarize_ds_models function (Issue #180) * Users to pass a list of models to summarize_ds_models rather than passing them individually. (Issue #149) * Truncation distances greater than the largest cutpoint value for binned data are no longer permitted as these cause fitting issues. (Issue #175) +* print.dht_result now displays estimates for groups as well as individuals by default when group size is present. (Issue #178) # Distance 2.0.0 diff --git a/R/print.dht_result.R b/R/print.dht_result.R index 0663409..7f7754d 100644 --- a/R/print.dht_result.R +++ b/R/print.dht_result.R @@ -4,30 +4,41 @@ #' #' @export #' @param x object of class `dht_result` -#' @param groups should abundance/density of groups be produced? +#' @param groups should abundance/density of groups be produced? TRUE +#' by default. #' @param report should `"abundance"`, `"density"` or `"both"` be reported? #' @param \dots unused -print.dht_result <- function(x, report="abundance", groups=FALSE, ...){ +print.dht_result <- function(x, report="abundance", groups=TRUE, ...){ + args <- list(...) + # Stop the general info being printed twice if there are groups + if(!is.null(args$skip.info)){ + skip.info <- args$skip.info + }else{ + skip.info <- FALSE + } + # general information - resulttype <- ifelse(report=="both", "abundance and density", report) - substr(resulttype, 1, 1) <- toupper(substr(resulttype, 1, 1)) - cat(resulttype, "estimates from distance sampling\n") - cat("Stratification :", attr(x, "stratification"), "\n") - cat("Variance :", paste0(attr(x, "ER_var")[[1]], ","), - ifelse(attr(x, "ER_var")[[3]], "binomial", - ifelse(attr(x, "ER_var")[[2]], "N/L", "n/L")), "\n") - cat("Multipliers :", ifelse(is.null(attr(x, "multipliers")), - "none", - paste(attr(x, "multipliers"), collapse=", ")), - "\n") - cat("Sample fraction :" , ifelse(is.data.frame(attr(x, "sample_fraction")), - "multiple", attr(x, "sample_fraction")), "\n") + if(!skip.info){ + resulttype <- ifelse(report=="both", "abundance and density", report) + substr(resulttype, 1, 1) <- toupper(substr(resulttype, 1, 1)) + cat(resulttype, "estimates from distance sampling\n") + cat("Stratification :", attr(x, "stratification"), "\n") + cat("Variance :", paste0(attr(x, "ER_var")[[1]], ","), + ifelse(attr(x, "ER_var")[[3]], "binomial", + ifelse(attr(x, "ER_var")[[2]], "N/L", "n/L")), "\n") + cat("Multipliers :", ifelse(is.null(attr(x, "multipliers")), + "none", + paste(attr(x, "multipliers"), collapse=", ")), + "\n") + cat("Sample fraction :" , ifelse(is.data.frame(attr(x, "sample_fraction")), + "multiple", attr(x, "sample_fraction")), "\n") + } cat("\n\n") - if(groups & !is.null(attr(x, "grouped"))){ - cat("Groups:\n\n") - print(attr(x, "grouped"), report=report) + if(groups && !is.null(attr(x, "grouped"))){ + cat("Groups:") + print(attr(x, "grouped"), report=report, skip.info = TRUE) cat("\n\n") cat("Individuals:\n\n") } diff --git a/man/print.dht_result.Rd b/man/print.dht_result.Rd index b1c8d99..9b848ef 100644 --- a/man/print.dht_result.Rd +++ b/man/print.dht_result.Rd @@ -4,14 +4,15 @@ \alias{print.dht_result} \title{Print abundance estimates} \usage{ -\method{print}{dht_result}(x, report = "abundance", groups = FALSE, ...) +\method{print}{dht_result}(x, report = "abundance", groups = TRUE, ...) } \arguments{ \item{x}{object of class \code{dht_result}} \item{report}{should \code{"abundance"}, \code{"density"} or \code{"both"} be reported?} -\item{groups}{should abundance/density of groups be produced?} +\item{groups}{should abundance/density of groups be produced? TRUE +by default.} \item{\dots}{unused} }