% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/design_expand.R
\name{design_expand}
\alias{design_expand}
\title{Dummy Expantion of a Vector}
\usage{
design_expand(
  x,
  type = 0,
  drop = "last",
  levels = NULL,
  froot = "level",
  sort = 0
)
}
\arguments{
\item{x}{a vector to be expanded}

\item{type}{= -1 for non-full-rank design matrix used in SAS proc GLM \cr
= 0  for zero-sum design matrix \cr
= 1  for drop-one-column design matrix \cr}

\item{drop}{= "last"   or    "first"  when type != -1\cr}

\item{levels}{= a string vector consisting of the labels for the levels}

\item{froot}{= A character to be used to name the columns of X matrix}

\item{sort}{= 1 to sort the levels as the native factor function does. \cr
This is the default behavior of native model.matrix function.}
}
\value{
Design matrix of the size length(x) times length(factor(x))
or length(x) times length(factor(x))-1
}
\description{
Dummy Expantion of a Vector
}
\details{
By default, the zero-sum design matrix with the last level dropped
will be generated.
}
\examples{
design_expand( c("a","b","c") )
design_expand( c("a","xb","c") )
design_expand( c("a","b","c"), sort=1 )

design_expand( c("a","b","c"), type=-1 )
design_expand( c("a","b","c"), levels=c("c","a","b"), type=-1 )

design_expand( 1:3, type=0 )
design_expand( c("a","b","c"), froot="A" )

}
