Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianGoueguel committed Jun 25, 2024
1 parent 1c2e1eb commit e8e786b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions R/outlierplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion man/outlierplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e8e786b

Please sign in to comment.