From c98a44122cdca868537e2f6615d96e68b4175c39 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Tue, 20 Oct 2020 17:22:50 -0600 Subject: [PATCH 1/3] Reorder new_data columns for glmnet --- R/linear_reg_data.R | 2 +- R/logistic_reg_data.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/linear_reg_data.R b/R/linear_reg_data.R index a877d2d19..83d94750e 100644 --- a/R/linear_reg_data.R +++ b/R/linear_reg_data.R @@ -168,7 +168,7 @@ set_pred( args = list( object = expr(object$fit), - newx = expr(as.matrix(new_data)), + newx = quote(as.matrix(new_data[, rownames(object$fit$beta)])), type = "response", s = expr(object$spec$args$penalty) ) diff --git a/R/logistic_reg_data.R b/R/logistic_reg_data.R index e86aad902..b777de456 100644 --- a/R/logistic_reg_data.R +++ b/R/logistic_reg_data.R @@ -187,7 +187,7 @@ set_pred( args = list( object = quote(object$fit), - newx = quote(as.matrix(new_data)), + newx = quote(as.matrix(new_data[, rownames(object$fit$beta)])), type = "response", s = quote(object$spec$args$penalty) ) From 3703b291662eab3e6ac8a521bdad196babb41872 Mon Sep 17 00:00:00 2001 From: Max Kuhn Date: Thu, 22 Oct 2020 20:16:25 -0400 Subject: [PATCH 2/3] multinomial fixes for #382 --- R/multinom_reg_data.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/multinom_reg_data.R b/R/multinom_reg_data.R index a352c8e34..5ff979a1d 100644 --- a/R/multinom_reg_data.R +++ b/R/multinom_reg_data.R @@ -61,7 +61,7 @@ set_pred( args = list( object = quote(object$fit), - newx = quote(as.matrix(new_data)), + newx = quote(as.matrix(new_data[, rownames(object$fit$beta[[1]])])), type = "class", s = quote(object$spec$args$penalty) ) @@ -80,7 +80,7 @@ set_pred( args = list( object = quote(object$fit), - newx = quote(as.matrix(new_data)), + newx = quote(as.matrix(new_data[, rownames(object$fit$beta[[1]])])), type = "response", s = quote(object$spec$args$penalty) ) From 3419f0e7fbf3cf684c9d2d4342e483af82147b06 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Thu, 22 Oct 2020 18:30:08 -0600 Subject: [PATCH 3/3] Use expr() rather than quote() --- R/linear_reg_data.R | 2 +- R/logistic_reg_data.R | 6 +++--- R/multinom_reg_data.R | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/linear_reg_data.R b/R/linear_reg_data.R index 83d94750e..0615b96d0 100644 --- a/R/linear_reg_data.R +++ b/R/linear_reg_data.R @@ -168,7 +168,7 @@ set_pred( args = list( object = expr(object$fit), - newx = quote(as.matrix(new_data[, rownames(object$fit$beta)])), + newx = expr(as.matrix(new_data[, rownames(object$fit$beta)])), type = "response", s = expr(object$spec$args$penalty) ) diff --git a/R/logistic_reg_data.R b/R/logistic_reg_data.R index b777de456..b170e64c3 100644 --- a/R/logistic_reg_data.R +++ b/R/logistic_reg_data.R @@ -186,10 +186,10 @@ set_pred( func = c(fun = "predict"), args = list( - object = quote(object$fit), - newx = quote(as.matrix(new_data[, rownames(object$fit$beta)])), + object = expr(object$fit), + newx = expr(as.matrix(new_data[, rownames(object$fit$beta)])), type = "response", - s = quote(object$spec$args$penalty) + s = expr(object$spec$args$penalty) ) ) ) diff --git a/R/multinom_reg_data.R b/R/multinom_reg_data.R index 5ff979a1d..52581622f 100644 --- a/R/multinom_reg_data.R +++ b/R/multinom_reg_data.R @@ -79,10 +79,10 @@ set_pred( func = c(fun = "predict"), args = list( - object = quote(object$fit), - newx = quote(as.matrix(new_data[, rownames(object$fit$beta[[1]])])), + object = expr(object$fit), + newx = expr(as.matrix(new_data[, rownames(object$fit$beta[[1]])])), type = "response", - s = quote(object$spec$args$penalty) + s = expr(object$spec$args$penalty) ) ) )