You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because I'm using a single string "any" as the marginal category. The error message:
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
This is an error in the stats::contrasts() function. The code:
function (x, how.many, value)
{
if (is.logical(x))
x <- factor(x, levels = c(FALSE, TRUE))
if (!is.factor(x))
stop("contrasts apply only to factors")
if (nlevels(x) < 2L)
stop("contrasts can be applied only to factors with 2 or more levels")
# ...
Oddly enough, using all ones instead of "any" works. My package relies on the mlr::createDummyFeatures() function. Perhaps I should write my own version of the function that handles this issue (and also remove a package dependency in the process).
The text was updated successfully, but these errors were encountered:
While explaining how to resolve issue #1, I realized that the following code will generate an error:
This is because I'm using a single string "any" as the marginal category. The error message:
This is an error in the
stats::contrasts()
function. The code:Oddly enough, using all ones instead of "any" works. My package relies on the
mlr::createDummyFeatures()
function. Perhaps I should write my own version of the function that handles this issue (and also remove a package dependency in the process).The text was updated successfully, but these errors were encountered: