contrasts {base} | R Documentation

## Get and Set Contrast Matrices

### Description

Set and view the contrasts associated with a factor.

### Usage

    contrasts(x)
    contrasts(x) <- ctr

### Arguments

`x` | a factor.
`ctr` | either a matrix whose columns give coefficients for contrasts in the levels of `x`, or the (quoted) name of a function which computes such matrices.

### Details

If contrasts are not set for a factor the default functions from `options("contrasts")` are used.

### See Also

`C`, `contr.helmert`, `contr.poly`, `contr.sum`, `contr.treatment`; `glm`, `aov`, `lm`.

### Examples

    example(factor)
    (fff <- factor(ff))
    contrasts(fff) # treatment
    contrasts(C(fff, sum))

[Package Contents]