Create overlapping bar and line plot using ggpubr

I am trying to make a overlaid plot, having 2 y-axes. I want one plot to be a bar plot, the other to be a line plot. I know how to do this in ggplot2 but I would like to learn how to do this using the ggpubr package. I'd be grateful for any insight anyone can provide! I know is is an elementary question, so thank you for bearing with me!

# Sample data
df1 <- data.frame(frax = c(16,30,60,64), solvb = c(0,0,100,100))
df2 <- data.frame(type = factor(c("mascot","mstat"), levels = c("mascot","mstat")), 
                 frax = c(30,35,40,45,50,55), phos = c(542,413,233,500,600,650))

This is what I'm looking for:
enter image description here

There is are a few examples of a secondary axis using sec.axis here:

Thanks! I am trying to do this using ggpubr rather than ggplot2 though. I know ggpubr is based off ggplot2, so the solution should be somewhat similar, but I haven't been able to figure it out. That was a very clear and helpful link though! Will definitely share with my fellow grad students.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.