Skip to contents

Return a matrix of independent contrasts – a level for each term.

Usage

contr.independent(n, contrasts = TRUE)

Arguments

n

a vector of levels for a factor, or the number of levels

contrasts

logical indicating whether contrasts should be computed

Value

A matrix with n rows and k columns, with k = n if contrasts = TRUE and k = n if contrasts = FALSE.

References

Examples

contr.independent(c(1, 2))
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
contr.independent(c(1, 2, 3))
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    0    1    0
#> [3,]    0    0    1