makeDmatrix: Make sparse matrix of dummies from factor list

View source: R/utils.R

makeDmatrixR Documentation

Make sparse matrix of dummies from factor list

Description

Given a list of factors, return the matrix of dummies as a sparse matrix.

Usage

makeDmatrix(fl, weights = NULL)

Arguments

fl

list of factors.

weights

numeric vector. Multiplied into the rows.

Details

The function returns the model matrix for a list of factors. This matrix is not used internally by the package, but it's used in some of the documentation for illustrative purposes.

Value

Returns a sparse matrix.

Examples


fl <- lapply(1:3, function(i) factor(sample(3, 10, replace = TRUE)))
fl
makeDmatrix(fl, weights = seq(0.1, 1, 0.1))


lfe documentation built on May 29, 2024, 7:39 a.m.