I have some data in a CSV that pertains to bandwidth tests, like so:
| Date.Time | Mean | Standard.Deviation |
|---|---|---|
| 2025/12/24 12:06:46 | 88382 | 6046 |
| 2025/12/24 12:22:59 | 93813 | 3986 |
| 2025/12/24 13:36:06 | 91530 | 8136 |
| 2025/12/24 13:49:28 | 86613 | 12586 |
| ... | ... | ... |
| 2026/02/26 09:56:33 | 53294 | 19979 |
| 2026/02/26 10:10:16 | 33435 | 16331 |
In RStudio, that data is in a frame with some other derived columns ("Day.of.Week", "Is.Business.Hours", etc.). I can filter on that data no problem.
The structure of the data frame is thus:
DATA2 %>% str
'data.frame': 6350 obs. of 13 variables:
$ Test.Number : int 1 2 3 ...
$ Epoch : int 1766596006 1766596979 1766598953 ...
$ Date.Time : chr "2025/12/24 12:06:46" "2025/12/24 12:22:59" ...
$ Date : Date, format: "2025-12-24" "2025-12-24" "2025-12-24" ...
$ Day.of.Week : chr "Wed" "Wed" "Wed" ...
$ Time : 'hms' num 12:06:46 12:22:59 12:55:53 ...
$ Is.Business.Hours : logi TRUE TRUE TRUE ...
$ Max : int 96460 95948 87756 ...
$ Mean : int 88382 93813 75173 ...
$ Min : int 74752 77312 55705 ...
$ Standard.Deviation: int 6046 3986 9306 ...
$ Std..Dev..Upper : int 94428 97799 84479 ...
$ Std..Dev..Lower : int 82336 89827 65867 ...
I am using this to show a graph of every 50th test.
DATA2 %>%
filter( Test.Number %% 50 == 0 ) %>%
ggplot2::ggplot() +
geom_col(aes(x = Date.Time, y = Mean, fill = Is.Business.Hours)) +
theme(axis.text.x = element_text(angle = -90, vjust = 0.5, hjust=1))
However, I'm not sure how to get "Mean" and "Standard.Deviation" into the chart. y = c(Mean, Standard.Deviation) doesn't seem to be a valid option within the aesthetic.
I would like to have the "Standard Deviation" value stacked on top of the "Mean" columns, where "stacked" means in the Z-axis (normal to the monitor), not a sum in the Y-axis. I did the below in LibreOffice as an example.
How would I replicate this same view in R/RStudio?


