Smooth a line plot having dates on x-axis

Hello colleagues,
I have small sample data set;

EMAILS_CLICKED EMAILS_NOT_CLICKED CLICK_PERCENT COHORT_NM ACTIVITY_DT
1            236               4395          5.37   Control  2019-11-17
2            243               4221          5.76      Test  2019-11-17
3            944               8283         11.40      Test  2019-11-18
4            807               8538          9.45   Control  2019-11-18
5            971               9472         10.25      Test  2019-11-19
6            942               9513          9.90   Control  2019-11-19

The goal is to plot a line plot with CLICK_PERCENT on y axis and ACTIVITY_DT on x axis. And we need two plots in the same graph for Test and Control cohorts. I have used the following code for this purpose;

ggplot(click_thru_rate_daily
, aes(x=as.Date(ACTIVITY_DT), y=CLICK_PERCENT,color=COHORT_NM)) +
geom_line()

And we get following jagged plot.

Is it possible to get a smoothed version for this plot? Help/code is greatly appreciated.

Try using geom_smooth instead of geom_line. Does that work for you?

2 Likes

Thanks for your advice.it works. for my purpose.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.