R/get_centroid.R

Defines functions get_centroid

Documented in get_centroid

get_centroid <- function(hv)
{
  if (class(hv)=="Hypervolume")
  {
    result = apply(hv@RandomPoints,2,mean)
    names(result) <- dimnames(hv@RandomPoints)[[2]]
    return(result)
  }
  else if (class(hv)=="HypervolumeList")
  {
    result = (sapply(hv@HVList, function(x) { apply(x@RandomPoints,2,mean) }))
    dimnames(result)[[2]] <- sapply(hv@HVList, function(x) {x@Name})
    return(t(result))
  }
  else
  {
    stop('Wrong class input.')
  }
}
dc165/Hypervolume-Dev documentation built on Dec. 13, 2020, 6:02 p.m.