as.Rvector {externalVector}R Documentation

convert an object to one of the most appropriate R basic vector

Description

as.Rvector, a generic, attempts to coerce its argument into a basic R vector of a convenient mode. All attributes of x are preserved.

Default methods are provided for basic R vectors which are returned unchanged.

Usage

as.Rvector(x)

Arguments

x An object

Details

This preserves all the non-slot attributes of the object x when converting to a basic R vector. In addition, if any of dim(x), dimnames(x), names(x) is not NULL, the corresponding attribute in the result is also set.

Value

The value is a basic R vector of mode "logical", "integer", "numeric", "complex", "character" or "list".

See Also

as.vector for converting an object to an appropriate vector with all attributes removed.

Examples

x <- 1:2
names(x) <- letters[1:2]
as.vector(x)
as.Rvector(x)

[Package Contents]