Factor with Chosen Contrasts

DESCRIPTION:
Returns a factor with a "contrasts" attribute.

USAGE:
C(object, contr, how.many)

REQUIRED ARGUMENTS:
object:
a factor or ordered factor.

OPTIONAL ARGUMENTS:
contr:
what contrasts to use. May be one of four standard names (helmert, poly, treatment, or sum), a function, or a matrix with as many rows as there are levels to the factor. The standard names must not be quoted. The default is the first element of the contrasts option for factors, and the second element of the option for ordered factors.
how.many:
the number of contrasts to be assigned to the factor. The default is k-1, where k is the number of levels.

VALUE:
a factor, with the contrasts attribute set as above.

DETAILS:
This may be used in a model formula or to create a new factor.

Note that setting how.many to be less than k-1 in a model formula is an assertion that the coefficients for the remaining factors are either known to be negligible or else should be aliased with other coefficients. The wafer example below is an example of aliasing the remaining contrasts.


SEE ALSO:
contrasts , contr.sum , aov , factor , ordered .

EXAMPLES:
# use treatment contrasts for factor Cat
aov(Yield ~ Cont* C(Cat, treatment), catalyst)

# only fit linear and quadratic effects aov(Defects ~ C(Reliability, poly, 2) * Type * Plant)

# partition spinsp into linear effect (the term with C) and # the higher order contrasts (the term with spinsp) # note that the order of the terms is important attach(wafer) aov(pre.mean ~ C(spinsp, poly, 1) + spinsp)