I'm trying to create a boxplot, but the only data I know is the min, max, median, lower fourth, upper fourth, and the outliers. This is my data:
I have been able to create the boxplot with:
dat<-read.table(text = "188.1 196.0 202.2 216.8 230.5")
dat<-t(dat)
bxp(list(stats=dat, n=rep(10, ncol(dat))))
But I don't know how to give it the outliers and make it show them. I've only found questions asking how to get rid of the outliers, but I need to know how to show them. How do I do this?
Just add additional arguments out
and groups
to the list of stats summaries you pass into bxp()
:
bxp(list(stats = dat, n = rep(10, ncol(dat)),
out = c(125.8, 250.2), groups = c(1,1)))
To see how you might have learned that yourself, check out ?bxp
, which includes this description of its first argument:
z: a list containing data summaries to be used in constructing
the plots. These are usually the result of a call to
‘boxplot’, but can be generated in any fashion.
Hmm. That looks promising. To learn more about exactly what sort of data summaries result from a call to boxplot()
, we can check out the "Value"
section ?boxplot
, where we find that it returns a list with the following components (among others):
out: the values of any data points which lie beyond the extremes
of the whiskers.
group: a vector of the same length as ‘out’ whose elements indicate
to which group the outlier belongs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With