[R] Function question
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Fri Oct 17 20:49:18 CEST 2008
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
More information about the R-help
mailing list