Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

c: Combine Values into a Vector or List

cR Documentation

Combine Values into a Vector or List

Description

This is a generic function which combines its arguments.

The default method combines its arguments to form a vector.All arguments are coerced to a common type which is the typeof the returned value, and all attributes except names are removed.

Usage

## S3 Generic functionc(...)## Default S3 method:c(..., recursive = FALSE, use.names = TRUE)

Arguments

...

objects to be concatenated. AllNULL entriesare dropped before method dispatch unless at the very beginning of theargument list.

recursive

logical. Ifrecursive = TRUE, the functionrecursively descends through lists (and pairlists) combining alltheir elements into a vector.

use.names

logical indicating ifnames should bepreserved.

Details

The output type is determined from the highest type of the componentsin the hierarchy NULL < raw < logical < integer < double < complex < character< list < expression. Pairlists are treated as lists, whereas non-vectorcomponents (such asnames /symbols andcalls)are treated as one-elementlistswhich cannot be unlisted even ifrecursive = TRUE.

Note that inR < 4.1.0,factors were treated only viatheir internalinteger codes: now there isc.factor method which combines factors into a factor.

c is sometimes used for its side effect of removing attributesexcept names, for example to turn anarray into a vector.as.vector is a more intuitive way to do this, but also dropsnames. Note that methods other than the default are not requiredto do this (and they will almost certainly preserve a class attribute).

This is a primitive function.

Value

NULL or an expression or a vector of an appropriate mode.(With no arguments the value isNULL.)

S4 methods

This function is S4 generic, but with argument list(x, ...).

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole.

See Also

unlist andas.vector to produceattribute-free vectors.

Examples

c(1,7:9)c(1:5, 10.5, "next")## uses with a single argument to drop attributesx <- 1:4names(x) <- letters[1:4]xc(x)          # has namesas.vector(x)  # no namesdim(x) <- c(2,2)xc(x)as.vector(x)## append to a list:ll <- list(A = 1, c = "C")## do *not* usec(ll, d = 1:3) # which is == c(ll, as.list(c(d = 1:3)))## but ratherc(ll, d = list(1:3))  # c() combining two listsc(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)

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2025 Movatter.jp