Learn R Programming

broman (version 0.98)

align_vectors: Align two vectors

Description

Align two vectors using their names attributes, either expanding with NAs or reducing to the common values.

Usage

align_vectors(x, y, expand = TRUE)

Value

A list with two components, x and y

Arguments

x

A vector

y

Another vector

expand

If TRUE, expand each to the same length using NAs. If FALSE, remove elements not in common.

Examples

Run this code
x <- c(a=1, b=2, c=3, d=4)
y <- c(b=1, c=2, e=3, a=4)
align_vectors(x,y)
align_vectors(x,y,expand=FALSE)

Run the code above in your browser using DataLab