I am quite new with r so bear with me please. I am plotting a daily avg temperature across a four month period. I want to be able to visualize the confidence I have across the data. I believe the best way to do this would be to visualize the confidence intervals across the graph. I basically just want a visualization of the spread of the data in a format similar to this one I saw (PLOT 2).
I used code from a prior stack overflow question similar to mine. I'm not fully understanding what the code is doing/performing so I am very likely wrong somewhere and just need some general direction in how to do this. Here is the code I am using.
library(ggplot2)
library(stats)
library(dplyr)
(ggplot(DailyAvgL5, aes(Date, mean_temp)) +
stat_summary(
geom = 'smooth',
fun.data = mean_cl_normal,
fun.args = list(conf.int = 0.95),
group = 1,
alpha = 0.5,
color = 'black',
se = TRUE)
)
The resulting graph is just the line graph, showing no visualization of spread.
Here is my data I am using for this graph
dput(head(DailyAvgL5))
structure(list(Date = structure(c(19791, 19792, 19793, 19794,
19795, 19796), class = "Date"), mean_temp = c(9.98765502929687,
9.884833984375, 8.01781209309896, 8.70198394775391, 9.21991678873698,
9.69807739257812), z_scoremean_temp = c(-1.34020216363965, -1.36818008165322,
-1.87620239793434, -1.69003716229342, -1.54910606620731, -1.41899711641255
), overallmean = c(14.9037835315265, 14.9037835315265, 14.9037835315265,
14.9037835315265, 14.9037835315265, 14.9037835315265)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
I think confidence intervals are what I am wanting to use. I initially tried to visualize the z scores but couldn't figure out a way either. Not sure what the best direction would be for visualizing the spread / confidence on this data. Thanks for the help!