Yousri Fanous
2020-May-02 23:30 UTC
[R] possible issue with scatterplot function in car package
library (car)
aa <- data.frame(x=c(2, 5, 6, 7, 8),
+ y=c(5, 10, 9, 12, 11),
+ ch=c("N", "Q", "R", "S",
"T"),
+ stringsAsFactors=FALSE)
scatterplot(aa$x,aa$y,smooth = FALSE, grid = FALSE, frame = FALSE,regLine=F)
Both x and y boxplots are correct
and in particular the median of the x box is at 6 which is confirmed
> median(aa$x)
[1] 6
Now I do only one addition to the scatterplot: I add
xlim> scatterplot(aa$x,aa$y,smooth = FALSE, grid = FALSE, frame
FALSE,regLine=F,xlim=c(0,8))
This causes the boxplot on x-axis to be in error:
1) the lower whisker starts now from zero
2) the median is between 4 and 6 and no longer at 6 as before
> sessionInfo()
R version 3.6.3 (2020-02-29)
[1] car_3.0-7
[[alternative HTML version deleted]]
Rolf Turner
2020-May-02 23:51 UTC
[R] [FORGED] possible issue with scatterplot function in car package
On 3/05/20 11:30 am, Yousri Fanous wrote:> library (car) > > aa <- data.frame(x=c(2, 5, 6, 7, 8), > + y=c(5, 10, 9, 12, 11), > + ch=c("N", "Q", "R", "S", "T"), > + stringsAsFactors=FALSE) > > scatterplot(aa$x,aa$y,smooth = FALSE, grid = FALSE, frame = FALSE,regLine=F) > > Both x and y boxplots are correct > and in particular the median of the x box is at 6 which is confirmed > >> median(aa$x) > [1] 6 > > Now I do only one addition to the scatterplot: I add xlim >> scatterplot(aa$x,aa$y,smooth = FALSE, grid = FALSE, frame > FALSE,regLine=F,xlim=c(0,8)) > > This causes the boxplot on x-axis to be in error: > 1) the lower whisker starts now from zero > 2) the median is between 4 and 6 and no longer at 6 as before > >> sessionInfo() > R version 3.6.3 (2020-02-29) > [1] car_3.0-7(1) Please present data using dput(); this makes life a lot easier for your respondents. (See posting guide.) (2) Please do not post in html. (See posting guide.) (3) I agree that this looks like a bug. (4) Email about issues like this should be sent to the maintainer of the package in question (see maintainer("car")) and not to r-help. cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276