[R] Fix warnings from R check --as-cran (#6374)

* Remove exit and printf.

* Fix warnings.
This commit is contained in:
Jiaming Yuan
2020-11-11 18:39:37 +08:00
committed by GitHub
parent 6e12c2a6f8
commit debeae2509
7 changed files with 42 additions and 20 deletions

View File

@@ -118,8 +118,7 @@ xgb.ggplot.shap.summary <- function(data, shap_contrib = NULL, features = NULL,
p_data <- prepare.ggplot.shap.data(data_list, normalize = TRUE)
# Reverse factor levels so that the first level is at the top of the plot
p_data[, "feature" := factor(feature, rev(levels(feature)))]
p <- ggplot2::ggplot(p_data, ggplot2::aes(x = feature, y = shap_value, colour = feature_value)) +
p <- ggplot2::ggplot(p_data, ggplot2::aes(x = feature, y = p_data$shap_value, colour = p_data$feature_value)) +
ggplot2::geom_jitter(alpha = 0.5, width = 0.1) +
ggplot2::scale_colour_viridis_c(limits = c(-3, 3), option = "plasma", direction = -1) +
ggplot2::geom_abline(slope = 0, intercept = 0, colour = "darkgrey") +

View File

@@ -212,6 +212,9 @@ xgb.plot.shap.summary <- function(data, shap_contrib = NULL, features = NULL, to
#' Prepare data for SHAP plots. To be used in xgb.plot.shap, xgb.plot.shap.summary, etc.
#' Internal utility function.
#'
#' @inheritParams xgb.plot.shap
#' @keywords internal
#'
#' @return A list containing: 'data', a matrix containing sample observations
#' and their feature values; 'shap_contrib', a matrix containing the SHAP contribution
#' values for these observations.