R/utils.getYColumns.R

Defines functions getYColumns

#' @title Get columns containing objective values.
#'
#' @details In ecr3 performance assessment a convention is that objective values
#' are stored in columns \dQuote{y1, ..., yn} where n is the number of objectives.
#' This function determines the objective columns and is called internally by most
#' functions of the performance assessment module.
#'
#' @param x [\code{data.frame}]\cr
#'   Data frame.
#' @return [\code{character}] Column names of objective columns.
getYColumns = function(x) {
  ns = colnames(x)
  if (any(is.na(ns)))
    BBmisc::stopf("[ecr3] Impossible to deduce columns of objectives, since (some) column names are missing.")
  obj.cols = ns[grepl("^y[0-9]+", ns)]
  return(obj.cols)
}
jakobbossek/ecr3 documentation built on Nov. 14, 2019, 7:47 p.m.