dfToSparse: Convert data frame to sparse matrix

Description Usage Arguments Value Examples

View source: R/dfToSparse.R

Description

dfToSparse performs one-hot encoding to characters and factor types within a data frame. The encoding is returned as a sparse matrix.

Usage

1
dfToSparse(x, transpose = FALSE)

Arguments

x

A data frame to convert into a sparse matrix. Only character and factor types are converted through one-hot encoding.

transpose

A boolean determining if you should query by columns instead of the default of rows (only for sparse matricies).

Value

A sparse matrix with one-hot encoded columns, numeric and integer columsn are preserved in this sparse matrix. Column names are returned.

Examples

1
2
x <- matrix(runif(20),10,2)
neighbors <- dfToSparse(x_df) 

jlisic/meanShiftR documentation built on Sept. 6, 2021, 8:27 p.m.