On 22/01/2008 6:51 AM, Thomas Steiner wrote: > Okay, let me try to better say what I meant: > > myfun1<-function(x=5,pa) { > return(pa[1]*x^2+pa[2]*x+pa[3]) > } > myfun2<-function(x=5,param,myfunk1) { > return(param[1]*myfunk1(x)+param[2]*myfunk1(x)) > } > test<-function(pars1,pars2,lo,up){ > mf=myfun1(x=2,pa=8*pars1) > integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=mf) > return( 2*integ$value ) > } > test(pars1=c(1,2,3),pars2=c(-1,1),lo=2,up=7) > > So the function myfun2 will be integrated and has a function (myfunk1) > itself as an argument.
You're not passing a function as myfunk1, you're passing mf, which is the result of evaluating myfun1, so it's a numeric vector. Duncan Murdoch > Why is this not possible? > Thanks, > Thomas > > PS: the "x=5" and "pa=8*" has no influence... > > ______________________________________________ > 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. ______________________________________________ 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.