EVOLUTION-MANAGER
Edit File: c.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: Combine Values into a Vector or List</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 {base}"><tr><td>c {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Combine Values into a Vector or List</h2> <h3>Description</h3> <p>This is a generic function which combines its arguments. </p> <p>The default method combines its arguments to form a vector. All arguments are coerced to a common type which is the type of the returned value, and all attributes except names are removed. </p> <h3>Usage</h3> <pre> ## S3 Generic function c(...) ## Default S3 method: c(..., recursive = FALSE, use.names = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>objects to be concatenated.</p> </td></tr> <tr valign="top"><td><code>recursive</code></td> <td> <p>logical. If <code>recursive = TRUE</code>, the function recursively descends through lists (and pairlists) combining all their elements into a vector.</p> </td></tr> <tr valign="top"><td><code>use.names</code></td> <td> <p>logical indicating if <code><a href="names.html">names</a></code> should be preserved.</p> </td></tr> </table> <h3>Details</h3> <p>The output type is determined from the highest type of the components in the hierarchy NULL < raw < logical < integer < double < complex < character < list < expression. Pairlists are treated as lists, whereas non-vector components (such names and calls) are treated as one-element lists which cannot be unlisted even if <code>recursive = TRUE</code>. </p> <p>Note that <code><a href="factor.html">factor</a></code>s are treated only via their internal <code><a href="integer.html">integer</a></code> codes; one proposal has been to use </p> <pre> c.factor <- function(..., recursive=TRUE) unlist(list(...), recursive=recursive)</pre> <p>if factor concatenation by <code>c()</code> should give a <code><a href="factor.html">factor</a></code>. </p> <p><code>c</code> is sometimes used for its side effect of removing attributes except names, for example to turn an array into a vector. <code>as.vector</code> is a more intuitive way to do this, but also drops names. Note that methods other than the default are not required to do this (and they will almost certainly preserve a class attribute). </p> <p>This is a <a href="Primitive.html">primitive</a> function. </p> <h3>Value</h3> <p><code>NULL</code> or an expression or a vector of an appropriate mode. (With no arguments the value is <code>NULL</code>.) </p> <h3>S4 methods</h3> <p>This function is S4 generic, but with argument list <code>(x, ...)</code>. </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="unlist.html">unlist</a></code> and <code><a href="vector.html">as.vector</a></code> to produce attribute-free vectors. </p> <h3>Examples</h3> <pre> c(1,7:9) c(1:5, 10.5, "next") ## uses with a single argument to drop attributes x <- 1:4 names(x) <- letters[1:4] x c(x) # has names as.vector(x) # no names dim(x) <- c(2,2) x c(x) as.vector(x) ## append to a list: ll <- list(A = 1, c = "C") ## do *not* use c(ll, d = 1:3) # which is == c(ll, as.list(c(d = 1:3))) ## but rather c(ll, d = list(1:3)) # c() combining two lists c(list(A = c(B = 1)), recursive = TRUE) c(options(), recursive = TRUE) c(list(A = c(B = 1, C = 2), B = c(E = 7)), recursive = TRUE) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>