I am trying to substitute values of an ff vector using two other vectors. With RAM objects it is straightforward:
w <- 3:6; w1 = 1:10; w2 = letters[1:10]
# a way to do it:
sapply(w, FUN=function(x){ w2[which(w1 == x)] } )
[1] "c" "d" "e" "f"
ff objects:
require(ff); require(ffbase)
z <- ff(3:6); z1 = ff(1:10); z2 = ff(factor(letters[1:10]))
How could I use ffvecapply
(or any other function) to achieve the result:
> z
ff (open) integer length=4 (4) levels: c d e f
[1] [2] [3] [4]
c d e f
I have checked this post, but
z <- ff(3:6)
y <- ff(z[], dim = c(1, 4))
z1 = ff(1:10); z2 = ff(factor(letters[1:10]))
y = as.ffdf(y)
lapply(physical(y), FUN=function(x){ z2[ffwhich(z1, z1 == x)] } )
Returns an error. Many thanks.