R/Factor2Binary.R

Defines functions Factor2Binary

Documented in Factor2Binary

Factor2Binary <- function(y, Name=NULL){  
  if (is.null(Name)) Name="C-"
  ncat=length(levels(y))
  n=length(y)
  Z=matrix(0,n,ncat)
  for (i in 1:n)
    Z[i,as.numeric(y[i])]=1
  colnames(Z) <- paste(Name,levels(y),sep="")
  return(Z)
}
villardon/MultBiplotR documentation built on June 5, 2021, 8:55 a.m.