vctrs (version 0.0.0.9000)

vec_c: Combine many vectors into one vector

Description

Combine all arguments into a new vector of common type.

Usage

vec_c(..., .ptype = NULL)

Arguments

...

Vectors to coerce.

.ptype

If NULL, the default, the output type is determined by computing the common type across all elements of ....

Alternatively, you can supply .ptype to give the output known type. If getOption("vctrs.no_guessing") is TRUE you must supply this value: this is a convenient way to make production code demand fixed types.

Value

A vector with class given by .ptype, and length equal to the sum of the vec_size() of the contents of ....

The vector will have names if the individual components have names (inner names) or if the arguments are named (outer names). If both inner and outer names are present, they are combined with a ..

Invariants

  • vec_size(vec_c(x, y)) == vec_size(x) + vec_size(y)

  • vec_type(vec_c(x, y)) == vec_type_common(x, y).

See Also

vec_cbind()/vec_rbind() for combining data frames by rows or columns.

Examples

Run this code
# NOT RUN {
vec_c(FALSE, 1L, 1.5)
vec_c(FALSE, 1L, "x", .ptype = character())

# Date/times --------------------------
c(Sys.Date(), Sys.time())
c(Sys.time(), Sys.Date())

vec_c(Sys.Date(), Sys.time())
vec_c(Sys.time(), Sys.Date())

# Factors -----------------------------
c(factor("a"), factor("b"))
vec_c(factor("a"), factor("b"))
# }

Run the code above in your browser using DataCamp Workspace