From 0523a258db79ed25c570a56d9b547b2bd051794a Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sat, 21 Oct 2023 08:48:35 +0200 Subject: [PATCH 1/2] Set `drop = TRUE` in `split.shapviz()` --- NEWS.md | 6 +++++- R/methods.R | 5 +++-- man/split.shapviz.Rd | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9330a6a..9e8c17e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,7 +10,11 @@ - `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. + +## Bug fixes + +- `sv_dependence2D()`: In case `add_vars` are passed, `x` and/or `y` are removed from it in order to not use any variable twice [#116](https://github.com/ModelOriented/shapviz/pull/116). +- `split.shapviz()` now drops empty levels. They launched an error because empty "shapviz" objects are currently not supported. # shapviz 0.9.2 diff --git a/R/methods.R b/R/methods.R index f504f4c..d5bc150 100644 --- a/R/methods.R +++ b/R/methods.R @@ -354,7 +354,8 @@ c.shapviz <- function(...) { #' #' @param x Object of class "shapviz". #' @param f Vector used to split feature values and SHAP (interaction) values. -#' @param ... Arguments passed to `split()`. +#' @param ... Arguments passed to `split()`. Don't pass `drop = TRUE` as empty +#' "shapviz" objects are rejected. #' @returns A "mshapviz" object. #' @examples #' \dontrun{ @@ -367,7 +368,7 @@ c.shapviz <- function(...) { #' @export #' @seealso [shapviz()], [rbind.shapviz()] split.shapviz <- function(x, f, ...) { - ind <- split(seq_len(nrow(x)), f = f, ...) + ind <- split(seq_len(nrow(x)), f = f, drop = FALSE, ...) mshapviz(lapply(ind, function(i) x[i, ])) } diff --git a/man/split.shapviz.Rd b/man/split.shapviz.Rd index 35227f2..e623554 100644 --- a/man/split.shapviz.Rd +++ b/man/split.shapviz.Rd @@ -11,7 +11,8 @@ \item{f}{Vector used to split feature values and SHAP (interaction) values.} -\item{...}{Arguments passed to \code{split()}.} +\item{...}{Arguments passed to \code{split()}. Don't pass \code{drop = TRUE} as empty +"shapviz" objects are rejected.} } \value{ A "mshapviz" object. From 5458cf6cb78f65e55f72738fbe5734105eb2aeff Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sat, 21 Oct 2023 08:52:25 +0200 Subject: [PATCH 2/2] Add PR to News --- NEWS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9e8c17e..67bfc64 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,8 +13,8 @@ ## Bug fixes -- `sv_dependence2D()`: In case `add_vars` are passed, `x` and/or `y` are removed from it in order to not use any variable twice [#116](https://github.com/ModelOriented/shapviz/pull/116). -- `split.shapviz()` now drops empty levels. They launched an error because empty "shapviz" objects are currently not supported. +- `sv_dependence2D()`: In case `add_vars` are passed, `x` and/or `y` are removed from it in order to not use any variable twice. [#116](https://github.com/ModelOriented/shapviz/pull/116). +- `split.shapviz()` now drops empty levels. They launched an error because empty "shapviz" objects are currently not supported. [#117](https://github.com/ModelOriented/shapviz/pull/117) # shapviz 0.9.2