[R] integral depending on a parameter
Rolf Turner
rolf.turner at xtra.co.nz
Sat Aug 6 01:00:11 CEST 2011
On 06/08/11 08:17, brunero liseo wrote:
> Is it possible to use the "integrate" function when it depends on a
> parameter?
> in other words can i get something like
>
> f(y) = integrate (g(x,y))?
> If not, how else can I get that?
> thanks in advance
This really boils down to ``RTFM''.
The help for "integrate" ``clearly'' ( :-) ) states that there is a
"..." argument
which consists of ``additional arguments passed to f''. So use it.
E.g.:
foo <- function(x,y){sin(x^2 + y^2)}
integrate(foo,0,2*pi,y=pi/4)
0.9314315 with absolute error < 1.5e-05
Most of the time, what you need to know is in the help. You just need
to learn to read the help *carefully* and think along the lines: ``This
*does* mean something useful and is actually expressed in a rational
albeit it cryptic manner. Given that fact, what could this *possibly*
mean?''
That will usually get you there. Then *try* what you think you gleaned
from the help using a *simple* example.
cheers,
Rolf Turner
More information about the R-help
mailing list