[R] Problem : solving a equation with R , fail with uniroot function

Peter Alspach PAlspach at hortresearch.co.nz
Wed Jun 10 02:13:31 CEST 2009


Tena koe Yann

It may not be the only problem, but you are missing an operator between
(bb0+x+1) and (bb1-x-1).

HTH ....

Peter Alspach

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of yann lancien
> Sent: Wednesday, 10 June 2009 9:31 a.m.
> To: r-help at r-project.org
> Subject: [R] Problem : solving a equation with R , fail with 
> uniroot function
> 
> Hi ,
> I would like to know if a R function have the same behaviour 
> than the matlab solve function.
> I tried something with uniroot but I have some problems:
> The equation I need to solve is :
> exp(c0-r0)*(bb0+x)*(bb1-x)=(bb0+x+1)(bb1-x-1)
> 
> So I tried this:
> 
> STEP 1: my function test
>  test <- function(x,bb0=-3,bb1=5,c0=2,r0=0) {
> + ((exp(c0-r0)*(bb0+x)*(bb1-x))/((bb0+x+1)(bb1-x-1))-1)}
> 
> STEP 2:
> > uniroot(test,c(-100,100))$root*
> Erreur dans f(lower, ...) :
>   tentative d'appliquer un objet qui n'est pas une fonction*
> 
> R tells me that test is not a function ...
> 
> STEP 3:
> > is.function(test)
> [1] TRUE
> 
> 
> Thanks,
> Yann
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
> 

The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.




More information about the R-help mailing list