EVOLUTION-MANAGER
Edit File: attr.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: Object Attributes</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 attr {base}"><tr><td>attr {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Object Attributes</h2> <h3>Description</h3> <p>Get or set specific attributes of an object. </p> <h3>Usage</h3> <pre> attr(x, which, exact = FALSE) attr(x, which) <- value </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>an object whose attributes are to be accessed.</p> </td></tr> <tr valign="top"><td><code>which</code></td> <td> <p>a non-empty character string specifying which attribute is to be accessed.</p> </td></tr> <tr valign="top"><td><code>exact</code></td> <td> <p>logical: should <code>which</code> be matched exactly?</p> </td></tr> <tr valign="top"><td><code>value</code></td> <td> <p>an object, the new value of the attribute, or <code>NULL</code> to remove the attribute.</p> </td></tr> </table> <h3>Details</h3> <p>These functions provide access to a single attribute of an object. The replacement form causes the named attribute to take the value specified (or create a new attribute with the value given). </p> <p>The extraction function first looks for an exact match to <code>which</code> amongst the attributes of <code>x</code>, then (unless <code>exact = TRUE</code>) a unique partial match. (Setting <code><a href="options.html">options</a>(warnPartialMatchAttr = TRUE)</code> causes partial matches to give warnings.) </p> <p>The replacement function only uses exact matches. </p> <p>Note that some attributes (namely <code><a href="class.html">class</a></code>, <code><a href="comment.html">comment</a></code>, <code><a href="dim.html">dim</a></code>, <code><a href="dimnames.html">dimnames</a></code>, <code><a href="names.html">names</a></code>, <code><a href="row.names.html">row.names</a></code> and <code><a href="../../stats/html/tsp.html">tsp</a></code>) are treated specially and have restrictions on the values which can be set. (Note that this is not true of <code><a href="levels.html">levels</a></code> which should be set for factors via the <code>levels</code> replacement function.) </p> <p>The extractor function allows (and does not match) empty and missing values of <code>which</code>: the replacement function does not. </p> <p><code><a href="NULL.html">NULL</a></code> objects cannot have attributes and attempting to assign one by <code>attr</code> gives an error. </p> <p>Both are <a href="Primitive.html">primitive</a> functions. </p> <h3>Value</h3> <p>For the extractor, the value of the attribute matched, or <code>NULL</code> if no exact match is found and no or more than one partial match is found. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="attributes.html">attributes</a></code> </p> <h3>Examples</h3> <pre> # create a 2 by 5 matrix x <- 1:10 attr(x,"dim") <- c(2, 5) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>