Learn R Programming

bigstatsr (version 1.6.1)

covar_from_df: Numeric matrix from data frame

Description

Transform a data frame to a numeric matrix by one-hot encoding factors. The last factor value is always omitted to prevent having a singular matrix when adding a column of 1s (intercept) in models.

Usage

covar_from_df(df)

Value

A numeric matrix.

Arguments

df

A data frame.

Examples

Run this code
mat <- covar_from_df(iris)
head(mat)

Run the code above in your browser using DataLab