diff --git a/R/outlierplot.R b/R/outlierplot.R index 0cedcc4..15c4af6 100644 --- a/R/outlierplot.R +++ b/R/outlierplot.R @@ -25,7 +25,7 @@ #' - A `ggplot` object with Mahalanobis distances color-coded (if `show.mahal = TRUE`) #' - A `ggplot` object combining both outlier highlighting and Mahalanobis distance color-coding #' (if both `show.outlier` and `show.mahal` are `TRUE`) -#' - A tibble containing standardized scores, outlier flags, and Mahalanobis distances +#' - A tibble containing standardized scores, outlier flags, and robust multivariate Mahalanobis distances #' (if both `show.outlier` and `show.mahal` are `FALSE`) #' #' @export outlierplot @@ -86,6 +86,7 @@ outlierplot <- function(x, quan = 1/2, alpha = 0.025, show.outlier = TRUE, show. s_df <- as.data.frame(sx) colnames(s_df) <- colnames(x) + set.seed(123) s_df <- s_df %>% tibble::as_tibble() %>% dplyr::mutate( @@ -131,9 +132,14 @@ outlierplot <- function(x, quan = 1/2, alpha = 0.025, show.outlier = TRUE, show. mid = "green", high = "blue", midpoint = 0) + - ggplot2::guides(color = ggplot2::guide_colorbar()) - - p_all <- p_mahal + ggplot2::aes(shape = outlier) + ggplot2::guides(color = ggplot2::guide_colorbar()) + + ggplot2::labs(color = "Robust\nMahalanobis") + + p_all <- p + + ggplot2::geom_point(ggplot2::aes(color = mahalanobis, shape = outlier)) + + ggplot2::scale_color_viridis_c(option = "plasma") + + ggplot2::scale_shape_manual(values = c("FALSE" = 1, "TRUE" = 17)) + + ggplot2::labs(color = "Robust\nMahalanobis", shape = "Outlier") if (show.outlier == TRUE && show.mahal == FALSE) { return(p_outl) diff --git a/man/outlierplot.Rd b/man/outlierplot.Rd index 9bce9e7..6effd8b 100644 --- a/man/outlierplot.Rd +++ b/man/outlierplot.Rd @@ -30,7 +30,7 @@ Depending on the combination of \code{show.outlier} and \code{show.mahal}: \item A \code{ggplot} object with Mahalanobis distances color-coded (if \code{show.mahal = TRUE}) \item A \code{ggplot} object combining both outlier highlighting and Mahalanobis distance color-coding (if both \code{show.outlier} and \code{show.mahal} are \code{TRUE}) -\item A tibble containing standardized scores, outlier flags, and Mahalanobis distances +\item A tibble containing standardized scores, outlier flags, and robust multivariate Mahalanobis distances (if both \code{show.outlier} and \code{show.mahal} are \code{FALSE}) } }