df <- data.frame(x1 = rnorm(10), x2 = rnorm(10), y = rbinom(10, 5, 0.5))
df$ny <- 5 - df$y
glmnet(cbind(ny, y) ~ x1 + x2, data=df, family="binomial", use.model.frame=TRUE)
#Error in glmnet::glmnet(x = xy$x, y = xy$y, weights = xy$weights, offset = xy$offset, :
# number of elements in weights (20) not equal to the number of rows of x (10)