Contrasts Attribute

DESCRIPTION:
Returns the matrix which is the "contrasts" attribute of an object.

USAGE:
contrasts(x)
contrasts(x, how.many=<<see below>>) <- value

REQUIRED ARGUMENTS:
x:
a factor or ordered factor.

OPTIONAL ARGUMENTS:
how.many:
the number of contrasts to make; this can be larger, smaller or the same as the number of columns in value. The default is to make one less than the number of levels in x.
value:
a matrix containing the same number of rows as there are levels in x. This is commonly the result of one of the standard contrast functions, such as contr.sum.

VALUE:
the value of the "contrasts" attribute.

SIDE EFFECTS:
the "contrasts" attribute is changed when an assignment is made to it.

DETAILS:
The "contrasts" option names the default contrast functions for factors and ordered factors. Thus, creating a "contrasts" attribute for an object is often unnecessary.

SEE ALSO:
contr.sum , C , options .

EXAMPLES:
contrasts(temp) <- contr.poly(3)

contrasts(treatment) <- contr.sum(5)[, 1:3] # resulting contrast has 4 columns, probably not what was intended

contrasts(treatment, 3) <- contr.sum(5)[, 1:3] # resulting contrast has 3 columns