R/linearAlgebra-vechsnames.R

Defines functions vechsnames

Documented in vechsnames

#' Vector Names for Strict Half-Vectorization
#'
#' Returns a character vector of length `0.5 * k * (k + 1) - k`
#' from an input vector `x` of length `k`.
#'
#' @author Ivan Jacob Agaloos Pesigan
#'
#' @inherit vechnames return
#' @inheritParams vechnames
#'
#' @examples
#' x <- diag(2)
#' colnames(x) <- rownames(x) <- c("x1", "x2")
#' vechsnames(colnames(x))
#'
#' x <- diag(3)
#' colnames(x) <- rownames(x) <- c("x1", "x2", "x3")
#' vechsnames(colnames(x))
#' @family Vectorization Functions
#' @keywords linearAlgebra vectorization
#' @export
vechsnames <- function(x,
                       sep = ".") {
  stopifnot(
    is.vector(x),
    length(sep) == 1
  )
  .vechsnames(
    x = x,
    sep = sep
  )
}
jeksterslab/linearAlgebra documentation built on Dec. 20, 2021, 10:10 p.m.