R/summary.parsec.R

Defines functions summary.parsec

Documented in summary.parsec

summary.parsec <-
function(object, ...) {
    
    if (!is.null(object$profiles)) {
        res <- object$profiles$profiles    
    } else {
        res <- data.frame(tmp = 1:object$number_of_profiles)
    }
    
    res$weights <- object$profiles_weights
    res$"threshold" <- object$threshold
    res$"id. function" <- object$identification_function
    res$"average rank" <- apply(
        object$rank_relative_frequencies,
        2,
        function(x) sum((1:object$number_of_profiles)*x)
    )
    res$"abs. poverty gap" <- object$point_absolute_poverty_gap
    res$"rel. poverty gap" <- object$point_relative_poverty_gap
    res$"abs. wealth gap" <- object$point_absolute_wealth_gap
    res$"rel. wealth gap" <- object$point_relative_wealth_gap
    
    if ("tmp" %in% names(res)) res$tmp <- NULL
    
    rownames(res) <- rownames(object$incidence)
    
    ord <- order(-res$"id. function", res$"average rank")
    res <- res[ord,]
    
    if (object$number_of_profiles < 11)
        print(res)
    else {
        print(res[1:5,])
        cat("\n...\n\n")
        print(res[object$number_of_profiles - 4:0,])
    }
    try(
        cat("\npoverty gap  = ", object$poverty_gap, "\n",
            "wealth gap   = ", object$wealth_gap, "\n", sep = "")
    , silent = TRUE)
    try(
    {
    if (!is.na(object$inequality)) {
        try(cat("inequality = ", object$inequality, sep = ""), silent = TRUE)
    } else {
        cat("inequality has not been evaluated")
    }
    cat("\n\nthis function returns a data.frame that summarize each profile\nyou can also summarize\n\n")
    }, silent = TRUE)
    invisible(res)
}

Try the parsec package in your browser

Any scripts or data that you put into this service are public.

parsec documentation built on May 2, 2019, 6:08 p.m.