Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R ff ffbase ffwhich error in a function call?

Tags:

r

Here is My code call ffwhich in a function:

library(ffbase)
rm(a,b)
test <- function(x) {
  a <- 1
  b <- 3
  ffwhich(x, x > a & x < b)
}
x <- ff(1:10)
test(x)
Error in eval(expr, envir, enclos) (from <text>#1) : object 'a' not found

traceback()
6: eval(expr, envir, enclos)
5: eval(e)
4: which(eval(e))
3: ffwhich.ff_vector(x, x > a & x < b)
2: ffwhich(x, x > a & x < b) at #4
1: test(x)

It may caused by lazy evaluation? The eval() can not find the a and b which is bounded in function test. How can I use ffwhich in a function?

  • R 2.15.2
  • ffbase 0.6-3
  • ff 2.2-10
  • OS opensuse 12.2 64 bit
like image 428
user1933794 Avatar asked Aug 24 '26 04:08

user1933794


1 Answers

Yes, it looks like an eval issue like Arun is indicating. I normally use the following when using ffwhich which is like an eval.

library(ffbase)
rm(a,b)
test <- function(x) {
  a <- 1
  b <- 3
  idx <- x > a & x < b
  idx <- ffwhich(idx, idx == TRUE)
  idx
}
x <- ff(1:10)
test(x)

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!