Displaying 2 results from an estimated 2 matches for "cutveri".
Did you mean:
cutvery
2018 Feb 08
2
sparse.model.matrix Generates Non-Existent Factor Levels if Ord.factor Columns Present
Good day,
Sometimes, sparse.model.matrix outputs a dgCMatrix which has column names consisting of factor levels that were not in the original dataset. The first factor appears to be correctly transformed, but the following factors don't. For example:
diamonds <- as.data.frame(ggplot2::diamonds)
> colnames(sparse.model.matrix(~ . -1, diamonds))
[1] "carat"
2018 Feb 08
0
sparse.model.matrix Generates Non-Existent Factor Levels if Ord.factor Columns Present
color and clarity are ordered factors, so sparse.model.matrix is
generating orthogonal-polynomial contrasts (see ?contr.poly). This is
by design ... what are you trying to do? Are you interested in fac2sparse?
On 18-02-07 11:00 PM, Dario Strbenac wrote:
> Good day,
>
> Sometimes, sparse.model.matrix outputs a dgCMatrix which has column names consisting of factor levels that were not