使用ffvecapply查找ff向量

时间:2014-07-02 13:57:46

标签: r lookup ff

我试图用另外两个向量替换ff向量的值。使用RAM对象很简单:

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"

对象:

require(ff); require(ffbase)
z <- ff(3:6); z1 = ff(1:10); z2 = ff(factor(letters[1:10]))

我如何使用ffvecapply(或任何其他功能)来实现结果:

> z
ff (open) integer length=4 (4) levels: c d e f
[1] [2] [3] [4] 
 c   d   e   f

我已查看this帖子,但

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)] } )

返回错误。非常感谢。

0 个答案:

没有答案