[R] adding percentage secondary y-axis
Eliza Botto
eliza_botto at outlook.com
Thu Nov 23 15:30:53 CET 2017
Dear useRs,
I have this dataset (D) with three columns.
> dput(D)
structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 2.990484802, 3.005018792, 3.019552781, 3.03408677,
3.048620759, 3.063154749, 3.077688738, 3.092222727, 3.106756717,
3.121290706, 3.135824695, 3.150358684, 3.164892674, 3.179426663,
3.193960652, 3.208494642, 3.223028631, 3.23756262, 3.252096609,
3.266630599, 0.488381368, 0.976762736, 1.465144104, 1.953525472,
2.44190684, 2.930288208, 3.418669576, 3.907050944, 4.395432311,
4.883813679, 5.372195047, 5.860576415, 6.348957783, 6.837339151,
7.325720519, 7.814101887, 8.302483255, 8.790864623, 9.279245991,
9.767627359), .Dim = c(20L, 3L))
The first column represents the index values while the second column contains the response values. The third column in actually the percentage increase in the response values by increasing a unit index value.
I made a plot and obtained a single line by;
>plot(D[,1],D[,2],type="l")
The primary y-axis represents the usual response values. Now I want to add a secondary y-axis representing the percentage value shown against response value. So that, when a reader sees the graph she could easily visualize not only the decimal response value but also the percentage increase against that response value from the secondary axis without plotting any extra line.
I thank you in advance,
Stay Blessed!!!!
Eliza
UoS
[[alternative HTML version deleted]]
More information about the R-help
mailing list