I have a large data set I am plotting in R, and I'd like to have an axis on each side of the graph show the data in two different scales. So for example, on the left vertical axis I'd like to plot the data directly (e.g. plot(y ~ x) ) and on the right axis, I'd like to have a linear scaling of the left axis. (e.g. plot( y*20 ~ x).
So there would only be one data set displayed, but the axes would show different meanings for those data points.
I've tried the following:
plot(x = dataset$x, y = dataset$y)
axis(4, pretty(dataset$y,10) )
This will correctly print a new right axis with the same scale as the default left axis. (essentially useless, but it works) However, if I make this tiny change:
plot(x = dataset$x, y = dataset$y)
axis(4, pretty(10*dataset$y,10) )
Suddenly, it refuses to add my new right axis. I suspect this has something to do with R seeing if the axis matches the data set in some way and rejecting it if not. How can I get R to ignore the data set and just print an arbitrary axis of my choosing?