% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hellinger.R
\name{build_matrix}
\alias{build_matrix}
\title{Convert a long dataframe to a wide (sparse) matrix}
\usage{
build_matrix(data, row, column, value, ..., sparse = TRUE)
}
\arguments{
\item{data}{Dataframe}

\item{row}{Column name to use as row names, as string or symbol}

\item{column}{Column name to use as column names, as string or symbol}

\item{value}{Column name to use as matrix values, as string or symbol}

\item{...}{Other arguments, passed to \code{Matrix::sparseMatrix}}

\item{sparse}{Should the matrix be a \code{Matrix} sparse matrix?}
}
\value{
A matrix or sparse Matrix object, with one row for each unique value in the row column, one column for each unique value in the column column, and with as many non-zero values as there are rows in data.
}
\description{
For the sparse case, an alias for \code{tidytext::cast_sparse}
}
\examples{
data.frame(id = c(1, 1, 2, 2) + 4,
           cols = c('a', 'b', 'a', 'b'),
           vals = 1:4) |>
    build_matrix(row = id, column = 'cols', value = vals)
}
