diff --git a/NEWS.md b/NEWS.md index c4b61c5..9330a6a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,7 @@ - `print.shapviz()` now shows top two rows of SHAP matrix. - Re-activate all unit tests. - Added "How to contribute" to README. +- `sv_dependence2D()`: In case `add_vars` are passed, `x` and/or `y` are removed from it in order to not use any variable twice. # shapviz 0.9.2 diff --git a/R/sv_dependence2D.R b/R/sv_dependence2D.R index 6f1e6f6..6f4455a 100644 --- a/R/sv_dependence2D.R +++ b/R/sv_dependence2D.R @@ -7,7 +7,8 @@ #' maybe other regional features that can be passed via `add_vars`). #' #' If SHAP interaction values are available, setting `interactions = TRUE` allows -#' to focus on pure interaction effects (multiplied by two). +#' to focus on pure interaction effects (multiplied by two). In this case, `add_vars` +#' has no effect. #' #' @importFrom rlang .data #' @@ -114,7 +115,7 @@ sv_dependence2D.shapviz <- function(object, x, y, # Color variable if (!interactions) { - s <- rowSums(S[, c(x, y, add_vars)]) + s <- rowSums(S[, unique(c(x, y, add_vars))]) # unique() if add_vars contains x or y } else { s <- S_inter[, x, y] if (x != y) { diff --git a/man/sv_dependence2D.Rd b/man/sv_dependence2D.Rd index 7a685ee..fb4d762 100644 --- a/man/sv_dependence2D.Rd +++ b/man/sv_dependence2D.Rd @@ -81,7 +81,8 @@ A typical application are models with latitude and longitude as features (plus maybe other regional features that can be passed via \code{add_vars}). If SHAP interaction values are available, setting \code{interactions = TRUE} allows -to focus on pure interaction effects (multiplied by two). +to focus on pure interaction effects (multiplied by two). In this case, \code{add_vars} +has no effect. } \section{Methods (by class)}{ \itemize{