[R] uniroot problem
tring @ending from gvdnet@dk
Wed Dec 19 10:53:49 CET 2018
Thanks a lot - f was renamed FF and things are OK
Fra: Berwin A Turlach <berwin.turlach using gmail.com>
Sendt: 19. december 2018 10:27
Til: Troels Ring <tring using gvdnet.dk>
Emne: Re: [R] uniroot problem
On Wed, 19 Dec 2018 10:03:09 +0100
"Troels Ring" <tring using gvdnet.dk> wrote:
> Dear friends and helpers - in the script below, uniroot is called with
> a function CHB that calls a function, Charge. On its own, CHB
> apparently does what is expected, but from within uniroot, problems
> appear. An error is thrown
> Error in f(lower, ...) : could not find function "f"
> So CHB is not seen or understood from within uniroot?
Read the help page of uniroot.
The first argument is called "f", it is the function for which the root is
searched. In your call:
You pass the object "f" (a vector "f <- c(1,1,1)" created earlier in your
code) to the argument "f". Presumably there is no function called "f" in
your search path, and so R correctly complains that it cannot find the
function whose root you are looking for.
In R, arguments are passed first by exact matching of actual and formal
arguments, then by partial matching and then by position.
The easiest fix is probably to rename the object "f" to something else.
More information about the R-help