EVOLUTION-MANAGER
Edit File: attrassign.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: Create new-style "assign" attribute</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 attrassign {survival}"><tr><td>attrassign {survival}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Create new-style "assign" attribute</h2> <h3>Description</h3> <p>The <code>"assign"</code> attribute on model matrices describes which columns come from which terms in the model formula. It has two versions. R uses the original version, but the alternate version found in S-plus is sometimes useful. </p> <h3>Usage</h3> <pre> ## Default S3 method: attrassign(object, tt,...) ## S3 method for class 'lm' attrassign(object,...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>object</code></td> <td> <p>model matrix or linear model object</p> </td></tr> <tr valign="top"><td><code>tt</code></td> <td> <p>terms object</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>ignored</p> </td></tr> </table> <h3>Details</h3> <p>For instance consider the following </p> <pre> survreg(Surv(time, status) ~ age + sex + factor(ph.ecog), lung) </pre> <p>R gives the compact for for assign, a vector (0, 1, 2, 3, 3, 3); which can be read as “the first column of the X matrix (intercept) goes with none of the terms, the second column of X goes with term 1 of the model equation, the third column of X with term 2, and columns 4-6 with term 3”. </p> <p>The alternate (S-Plus default) form is a list </p> <pre> $(Intercept) 1 $age 2 $sex 3 $factor(ph.ecog) 4 5 6 </pre> <h3>Value</h3> <p>A list with names corresponding to the term names and elements that are vectors indicating which columns come from which terms </p> <h3>See Also</h3> <p><code><a href="../../stats/html/terms.html">terms</a></code>,<code><a href="../../stats/html/model.matrix.html">model.matrix</a></code></p> <h3>Examples</h3> <pre> formula <- Surv(time,status)~factor(ph.ecog) tt <- terms(formula) mf <- model.frame(tt,data=lung) mm <- model.matrix(tt,mf) ## a few rows of data mm[1:3,] ## old-style assign attribute attr(mm,"assign") ## alternate style assign attribute attrassign(mm,tt) </pre> <hr /><div style="text-align: center;">[Package <em>survival</em> version 2.44-1.1 <a href="00Index.html">Index</a>]</div> </body></html>