Solved – Box plot with just two values does not have its whiskers in R

boxplotr

Are boxplots by default unable to produce the whiskers when there are just 2 values being input?

I am working with dataset rufi and the values input are 0.939425 and 0.734522222. The boxplot command yields only the box without the whiskers. The box has the upper edge as the max value and the lower edge as the minimum value.

Am I doing something wrong here?

EDIT:
I am working with a dataset refined of 254 datapoints that are in 12 different groups and would like to compare the parameters with boxplots between the 12 groups. To do so I worked with boxplot(refined$highfeq ~ refined$taxa)

enter image description here

But this had a problem with small datasets (of 2) for some groups which resulted in the box plots plotting without whiskers and the lower and upper limits of the box plotting the min and max values respectively (see pink plot). This outcome is due to the fivesum function applied by the boxplot function which calculated the lower-hinge and upper-hinge to be equal to the min and max.

Is there a way to get R to plot the boxplots using exact percentiles instead of the fivesum function?

Best Answer

R's boxplot function, by default, uses boxplot.stats to calculate the boxes, whiskers, etc... boxplot.stats calls the fivenum function:

 > fivenum(c(0.734522222, 0.939425))
 [1] 0.7345222 0.7345222 0.8369736 0.9394250 0.9394250

According to ?fivenum:

Tukey's five number summary (minimum, lower-hinge, median, upper-hinge, maximum)

The minimum and lower-hinge are identical. Similarly, the upper-hinge and maximum are identical.