Learn R Programming

corpora (version 0.6)

rowColVector: Propagate vector to single-row or single-column matrix (corpora)

Description

This utility function converts a plain vector into a row or column vector, i.e. a single-row or single-column matrix.

Usage

rowVector(x, label=NULL)
colVector(x, label=NULL)

Value

A single-row or single-column matrix of the same data type as x. Labels of x are preserved as column/row names of the matrix.

See matrix for details on how non-atomic objects are handled.

Arguments

x

a (typically numeric) vector

label

an optional character string specifying a label for the single row or column returned

Author

Stephanie Evert (https://purl.org/stephanie.evert)

Examples

Run this code
rowVector(1:5, "myvec")
colVector(c(A=1, B=2, C=3), label="myvec")

Run the code above in your browser using DataLab