I am trying to create lines in my ggplot from lowest value to highest value on each date. I don't want any lines between each date (so adding geom_line does not work).
I have a dataset with dates from February 22nd to March 11th with abnormal returns from many different companies for each date. (There are some dates that stand out, hence the added geom_point) Image: The graph at this point
Right now you see only points on each date. I want a line added on here from the lowest point to the highest.
df_range <- df %>% group_by(date) %>%
summarise(lower = min(reaction), upper = max(reaction))
plot_df <- ggplot(df, aes(date, reaction))+
ggtitle('Abnormal returns for all companies')+
scale_x_bd( ## only using businessdays
business.dates = df$date,
max.major.breaks = 20,
labels = date_format("%b-%d"))+
geom_point()+
geom_hline(yintercept = 0)+
theme_bw()+
xlab("Date")+ ylab("Estimate")+
geom_point(aes(x = date, y = reaction), col = "red", data = date_Feb24_all_subdf, size=2)+
geom_point(aes(x = date, y = reaction), col = "red", data = date_Feb28_all, size=2, )+
geom_point(aes(x = date, y = reaction), col = "red", data = date_Mar7_all, size=2)+
geom_point(aes(x = date, y = reaction), col = "red", data = date_Mar8_all, size=2)+
geom_pointrange(aes(ymin = lower, ymax = upper), data= df_range)
plot_df
When I run the code I get this error: Error in FUN(X[[i]], ...) : object 'reaction' not found
I can run the code without the last line (geom_pointrange) and I get the image added above.
What can I do to also add the lines? Thank you.