I plotted an expression curve, i.e.curve(-log((1-x)/0.9999)/x,ylim=c(0,4))
.
However, I want to see the reverse relationship, i.e. y changes over x
instead of x changes over y
. Are there any R function can plot it automatically? Or a function that can solve the equation?
Asked
Active
Viewed 233 times
1 Answers
2
There are two obvious choices:
(i) derive the inverse function algebraically (trivial in this case),
That is, take y=-log((1-x)/0.9999) and make x the subject of the equation (which would require straightforward algebraic manipulation suitable for a question on math.SE if it's not obvious how to proceed)...
... and then use curve
on the result of that, or
(ii) use plot
rather than curve
to plot a set of (x,y) pairs (set type="l"
to get a curve), and simply interchange which is x and which is y in the call to plot.

Glen_b
- 7,883
- 2
- 37
- 48
-
The (i) choice I know, but suppose there's a complex equation and I just simply want to ask R for help in plotting, I don't want to solve (or I can't solve), the (ii) is ok but this is one step in a simulation process so... – Verbal Mar 23 '14 at 14:37
-
Kinh - your comments are insufficiently clear for me to respond. If you want answers to a different question to the one you asked, could you modify your post to ask that different question, please? (You'll need to make your requirements and conditions substantially more explicit. You'll probably need to comment under my answer to say you've done it, so I notice.) – Glen_b Mar 23 '14 at 19:57