[R] Error in f(x, ...) : could not find function "f2"

. . xkziloj at gmail.com
Tue Aug 30 14:31:06 CEST 2011


Hi all,

I am getting the erro showed in the subject. I was strange the this
becomes to happen after a computer restar. I think after the restart
another function f2 was in memory and it scape from me.

func <- Vectorize(FUN=
  function(y, frac, rate, sad, samp="Poisson", trunc=0, ...){
		f0 <- function(y,frac,n) {
			f1 <- function(y,frac,n){
				dpois(y,frac*n)
			}
			dcom <- paste("d",deparse(substitute(sad)),sep="")
			dots <- c(as.name("n"),list(...))
			f2 <- call(dcom,dots)
			f <- function(n){
				f1(y,frac,n)*f2(n)
			}
			myintegrate <- function() {
				r <- 0
				r1 <- 1
				x1 <- 0
				dx <- 20
				while(r1 > 10e-500) {
					r1 <- integrate(f,x1,x1+dx)$value
					r <- r + r1
					x1 <- x1 + dx
				}
				integrate(f,x1,Inf)$valu
			}
			myintegrate()
		}
		f0(y,frac,n)/(1-f0(trunc,frac,n))
	},"y")

func(10, 0.1, 0.1, exp)

Any idea?

Thanks in advance.



More information about the R-help mailing list