R/makelabelmaatrix.R

Defines functions makelabelmatrix

Documented in makelabelmatrix

#' Label matrix
#'
#' Convert class indicator into a label maxtrix.
#' @param clust An n-dimensional vector of class partition.
#' @return
#' \item{Z}{ A matrix of class indicator.}
#' @examples
#' cluster<-c(1,1,2,2,3,3)
#' label_maxtrix<-makelabelmatrix(cluster)
#' @export
makelabelmatrix <- function(clust){
  n <- length(clust)
  g <- max(clust)
  Z <- matrix(0, n, g)
  index <- cbind(1:n, clust)
  Z[index] <- 1
  return(Z)
}

Try the gmmsslm package in your browser

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

gmmsslm documentation built on June 8, 2025, 2 p.m.