Some data:
webdata <- structure(list(date = structure(c(18628, 18629, 18630, 18631,
18632), class = "Date"), sessions = c(9413.09630501196, 10444.2086439549,
10364.6407811647, 10746.5345515247, 10354.2723230473), conversions = c(209.25779246474,
282.459855790002, 111.936300864853, 145.978069189652, 300.705073793032
), conversion_rate = c(0.0222304952253937, 0.0270446393230081,
0.0107998244443041, 0.0135837342251824, 0.0290416423685998)), class = "data.frame", row.names = c(NA,
-5L))
Looks like this:
webdata
date sessions conversions conversion_rate
1 2021-01-01 9413.096 209.2578 0.02223050
2 2021-01-02 10444.209 282.4599 0.02704464
3 2021-01-03 10364.641 111.9363 0.01079982
4 2021-01-04 10746.535 145.9781 0.01358373
5 2021-01-05 10354.272 300.7051 0.02904164
I'd like a plot with sessions as columns using the left hand y axis and then a line for conversion rate using the right hand axis.
I can make the sessions column chart:
webdata %>% ggplot(aes(date, sessions)) +
geom_col(fill = 'steelblue')
Looks like this:
Here's an example using GSheets of what I'd like to achieve with ggplot:
The blue columns represent sessions and are measured against the left hand y axis, while the red line represents conversion rate and is measured against the right side y axis.
Is this possible with ggplot? Either with ggplot directly or by transforming my data in some way?