Learn R Programming

svs (version 3.0.0)

vec2ind: Transform a Vector into an Indicator Matrix

Description

A helper function for transforming a vector into an indicator matrix.

Usage

vec2ind(x, add_names = TRUE)

Arguments

x

A vector (which will internally be converted to a factor).

add_names

Logical specifying whether to add dimnames to the resulting indicator matrix.

Value

An indicator matrix.

Details

As of version 2.0.x of the svs package, this is essentially a wrapper for t(fac2sparse()) from the Matrix package.