-1

Is there a way I can show the "five values" in a boxplot by using R?

p0.3 = dbinom(0:60, 60, 0.3)
p0.5 = dbinom(0:60, 60, 0.5)
p0.8 = dbinom(0:60, 60, 0.8)
boxplot(p0.3,p0.5,p0.8,  names=c("0.3","0.5","0.8"),col=c("red","yellow","blue"),main = "Boxplot of Probability Distribution ", ylab = "Distribution Density", xlab = "Probability")
Chuck
  • 998
  • 8
  • 17
  • 30
Dido Du
  • 1
  • 4

1 Answers1

0

It is not clear to me if you want to plot symbols or the values themselves. It the first, you can just add things to you plot like:

abline(h=mean(p0.3), col ="red");
points(sd(p0.3), pch=18, col ="red")

If it's the second, you can calculate those statistics by your own and then add the values as text:

p0.3 = dbinom(0:60, 60, 0.3)
 p0.5 = dbinom(0:60, 60, 0.5)
p0.8 = dbinom(0:60, 60, 0.8)
 boxplot(p0.3,p0.5,p0.8,  names=c("0.3","0.5","0.8"),col=c("red","yellow","blue"),main = "Boxplot of Probability Distribution ", ylab = "Distribution Density", xlab = "Probability")

means <- mean(p0.3, na.rm = TRUE)

text(x=means, labels = means, y=0.01) # you will need to adjust y
daniel
  • 1,186
  • 2
  • 12
  • 21