简体   繁体   中英

Solve or plot the reverse of an equation in R

I plotted an expression curve, ie curve(-log((1-x)/0.9999)/x,ylim=c(0,4)) . However, I want to see the reverse relationship, ie 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM