I am trying to plot graph with 2 y-axis.
I did follow the steps mentioned in below link but it is not working. I also tried adding inherit.aes=FALSE but no result.
What is the simplest way to control the y-axis when using sec.axis
ggplot(data=sumdata.mas3, aes(x=test.percent, y=ticks)) + geom_point(color=test.percent,group=test.percent) +
  geom_errorbar(aes(ymin=ticks-sd, ymax=ticks+sd), width=.1) +
  geom_point(data=sumdata.mas4, aes(x=test.percent, y=max.infected))  +
  scale_y_continuous(limits=c(0, 850), sec.axis = sec_axis(~ . * 0.1, name =  "max infected"))
this gives error:
Error in layer(data = data, mapping = mapping, stat = stat, geom = GeomPoint, : object 'test.percent' not found
ggplot(sumdata.mas3, aes(x=test.percent, y=ticks, colour=test.percent, group=test.percent)) + 
  geom_errorbar(aes(ymin=ticks-sd, ymax=ticks+sd), width=.1) +
  labs(x="Test percentage", y="Total Ticks", title = "Test % vs Time") +
  geom_line() +
  geom_point()
This above code for only 1 y-axis works good but when I try to add 2nd one it gives error.
 
    