covar_from_df: Numeric matrix from data frame

View source: R/utils.R

covar_from_dfR Documentation

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)

Arguments

df

A data frame.

Value

A numeric matrix.

Examples

mat <- covar_from_df(iris)
head(mat)

bigstatsr documentation built on Oct. 14, 2022, 9:05 a.m.