1
votes

I have some monthly time-series data and I need to create a boxplot on this data using R. Until here, no problem of course. Then, additionally to the median, 1st quartile and 3rd quartile, I also need to visualize in the graph specific data points coming from the time-series, namely the observations at 3 years, 1 year and 3 months in the past. I looked online but I can't seem to find any command for this. Is there a way I can add these observation to the boxplot?

1
When you use boxplot you may use points(..., add=TRUE) to easily achieve an overlay of a boxplot with points! - jay.sf

1 Answers

1
votes

You can use, for example, the text function:

set.seed(123)
x <- rnorm(100, 5, 10)

If you want to display the mean value:

boxplot(x)
text(1, mean(x), "x", col = "red")

Additionally or alternatively, you can use the function points:

points(IQR(x), col = "blue", pch = 8)

enter image description here