[R] Uniroot error message with in intergration

S Ellison S.Ellison at LGCGroup.com
Sat Jun 23 02:40:32 CEST 2012



> Error in uniroot(integ, lower = 0, upper = 1000, n) :
>  'interval' must be a vector of length 2 >>>

> Please  would you be able to  give me an indication on why I am having this
> error message.

Because uniroot has a second parameter called 'interval' which overrides lower and upper and you have given uniroot a scalar called n as the first non-named argument. R has used its usual positional matching rules, which say that "Any unmatched formal arguments are bound to unnamed supplied arguments, in order." your first unmatched formal argument (interval) has been matched to your first unnamed argument (n) so uniroot has tried to use n as your interval.

You need to add your own parameters as named parameters; eg if your function took something called N, you would specify N=n

S Ellison

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list