Add drop = FALSE in regressor_coefficients()

Add `drop = FALSE` in definition of `regressor_coefficients()` to handle the case when there is only one additional regressor.
This commit is contained in:
markseeto 2021-05-21 17:45:18 +10:00 committed by GitHub
parent b75844e07c
commit e69f2f503f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,7 +38,7 @@ regressor_coefficients <- function(m){
regr_mus <- unlist(lapply(m$extra_regressors, function (x) x$mu))
regr_stds <- unlist(lapply(m$extra_regressors, function(x) x$std))
beta_indices <- which(m$train.component.cols[, regr_names] == 1, arr.ind = TRUE)[, "row"]
beta_indices <- which(m$train.component.cols[, regr_names, drop = FALSE] == 1, arr.ind = TRUE)[, "row"]
betas <- m$params$beta[, beta_indices, drop = FALSE]
# If regressor is additive, multiply by the scale factor to put coefficients on the original training data scale.
y_scale_indicator <- matrix(