R/make.metric_fun.R

Defines functions check.metric

## Checking class metric
check.metric <- function(metric) {
    ## Testing the metric
    try(some_name.that.probAbly.doesnt.ExIsT <- metric(matrix(rnorm(25), 5, 5)), silent = TRUE)
    ## If function worked
    if(exists("some_name.that.probAbly.doesnt.ExIsT")) {
        ## Is it a summary metric (one value)?
        if(length(some_name.that.probAbly.doesnt.ExIsT) == 1) {
            return("summary.metric")
        } else {
            return("class.metric")
        }
    } else {
        stop("Invalid metric.", call. = FALSE)
    }
}
TGuillerme/dispRity documentation built on Aug. 15, 2024, 12:16 p.m.