EVOLUTION-MANAGER
Edit File: zC.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Sets Contrasts for a Factor</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for C {stats}"><tr><td>C {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Sets Contrasts for a Factor</h2> <h3>Description</h3> <p>Sets the <code>"contrasts"</code> attribute for the factor. </p> <h3>Usage</h3> <pre> C(object, contr, how.many, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>object</code></td> <td> <p>a factor or ordered factor</p> </td></tr> <tr valign="top"><td><code>contr</code></td> <td> <p>which contrasts to use. Can be a matrix with one row for each level of the factor or a suitable function like <code>contr.poly</code> or a character string giving the name of the function</p> </td></tr> <tr valign="top"><td><code>how.many</code></td> <td> <p>the number of contrasts to set, by default one less than <code>nlevels(object)</code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>additional arguments for the function <code>contr</code>.</p> </td></tr> </table> <h3>Details</h3> <p>For compatibility with S, <code>contr</code> can be <code>treatment</code>, <code>helmert</code>, <code>sum</code> or <code>poly</code> (without quotes) as shorthand for <code>contr.treatment</code> and so on. </p> <h3>Value</h3> <p>The factor <code>object</code> with the <code>"contrasts"</code> attribute set. </p> <h3>References</h3> <p>Chambers, J. M. and Hastie, T. J. (1992) <em>Statistical models.</em> Chapter 2 of <em>Statistical Models in S</em> eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="contrasts.html">contrasts</a></code>, <code><a href="contrast.html">contr.sum</a></code>, etc. </p> <h3>Examples</h3> <pre> ## reset contrasts to defaults options(contrasts = c("contr.treatment", "contr.poly")) tens <- with(warpbreaks, C(tension, poly, 1)) attributes(tens) ## tension SHOULD be an ordered factor, but as it is not we can use aov(breaks ~ wool + tens + tension, data = warpbreaks) ## show the use of ... The default contrast is contr.treatment here summary(lm(breaks ~ wool + C(tension, base = 2), data = warpbreaks)) # following on from help(esoph) model3 <- glm(cbind(ncases, ncontrols) ~ agegp + C(tobgp, , 1) + C(alcgp, , 1), data = esoph, family = binomial()) summary(model3) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>