try uniroot(), e.g.,

f <- function (x) x^2
uniroot(function(x, a) f(x) - a, c(0, 10), a = 4)


I hope it helps.

Best,
Dimitris


dennis11 wrote:
Hi,

Let's say very simply there is a function:

f <- function (x) x^2

which is evaluated with :

f(2)

Now, I want to do the reverse so I want to now x for f(x) = 4

So, is there a way in R to solve x for some function f(x)=a?

I hope I explained it clear.

cheers,

Dennis


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to