I have a large dataset that I draw in R, and I would like the axis on each side of the graph to display data at two different scales. So, for example, on the left vertical axis, I would like to directly plot the data (for example, a graph (y ~ x)) and on the right axis, I would like to have linear scaling of the left axis. (e.g. graph (y * 20 ~ x).
Thus, only one data set will be displayed, but the axes will show different values ββfor these data points.
I tried the following:
plot(x = dataset$x, y = dataset$y) axis(4, pretty(dataset$y,10) )
This correctly prints the new right axis at 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 he refuses to add my new right axis. I suspect that this is due to the fact that R sees that the axis corresponds to a specific data set and rejects it if not. How can I make R ignore a dataset and just print an arbitrary axis of my choice?
source share