Hi:
integrate() is not a vectorized function. This appears to work:
sapply(1:2, function(x) func(x, 0.1, 0.1, sad = Exp))
[1] 0.250 0.125
In this case, sapply() is a disguised for loop.
HTH,
Dennis
On Mon, Aug 29, 2011 at 9:45 AM, . . wrote:
> Ooops,
>
> sorry!
>
> The problem occurs when
>
>
Ooops,
sorry!
The problem occurs when
func(1:2,0.1,0.1,sad=Exp)
On Mon, Aug 29, 2011 at 12:27 PM, R. Michael Weylandt
wrote:
> Can't help, code runs fine on my machine once you change "valu" to "value."
> Are you sure it fails in a vanilla run of R and isn't caused by any other
> choices you h
Can't help, code runs fine on my machine once you change "valu" to "value."
Are you sure it fails in a vanilla run of R and isn't caused by any other
choices you have made along the way?
Michael
PS -- Here's the code
func <- function(y, a, rate, sad){
f3 <- function(z){
f1 <- functio
Why I am getting
Error in integrate(f, x1, x1 + dx) :
maximum number of subdivisions reached
and can I avoid this?
func <- function(y, a, rate, sad){
f3 <- function(z){
f1 <- function(y,a,n){
dpois(y,a*n)
}
f2 <- function(n,rate){
dexp(n,rate)
}
f <- function(n){
f1(y,a,n
4 matches
Mail list logo