I used the regular "boxplot" function to check my data for extreme values. For presentations within the project, I then created the same boxplots using the package ggpubr (which builds on ggplot2).
As far I understood the whiskers should represent the same area in both blots. To my surprise, an extreme value appears in the ggpubr boxplot, which is not shown in the r-boxplot.
Code R-Boxplot:
boxplot(data$vtrust_post1, data$vtrust_post2)
Code Ggpubr:
vtrust_a_b_long %>%
ggboxplot(x = "drive", y = "count", bxp.errorbar = TRUE)
For ggpubr I had to convert the data to long format:
vtrust_a_b <- data.frame("subject_no" = data$id, "a" = data$vtrust_post1, "b" = data$vtrust_post2)
vtrust_a_b_long <- vtrust_a_b %>%
gather(key = "drive", value = "count", a, b)
Did I do something wrong? Both data contain the same maximum value. Could it be that the extreme values are defined differently in r-boxplot and ggpubr/ggplot2?
I am very grateful for your help!
UPDATE: Code to reproduce the problem
Using this code it indicates an extremevalue only for the ggpubr version.
a <- c(1.50, 3.50, 1.50, 3.00, 1.25, 5.25, 2.50, 2.50, 1.50, 2.25, 1.75, 2.25, 2.25, 2.25, 4.50, 2.25, 3.25, 1.25, 2.50, 2.75, 1.75, 4.25, 2.75, 2.00,
1.75, 3.50, 3.25, 3.00, 1.25, 1.25, 3.75, 1.50, 1.75, 2.25, 1.25, 2.00, 1.50, 3.50, 1.75, 3.25)
boxplot(a)
ggpubr::ggboxplot(a)
Update 2 Because of the hint, it could be caused by local settings within R, I tried the code at https://rdrr.io/snippets/. Again, the discrepancy occurs: