Why merge does not work on ffdf casted from ff_matrix

139 views Asked by At

Why doesn't merge work in the following? It gives error `Error:

require(ff)
require(ffbase)


a <- ffbase:::as.ff_matrix.ffdf(as.ffdf(data.frame(matrix(rnorm(10),ncol=2))))
b <- ffbase:::as.ff_matrix.ffdf(as.ffdf(data.frame(matrix(rnorm(10),ncol=2))))

a <- as.ffdf(a)
b <- as.ffdf(b)

colnames(a) <- 1:2
colnames(b) <- 3:4

a$RN <- as.ff(1:5)
b$RN <- as.ff(1:5)

c <- merge(a,b,by="RN") #ERROR

However if I do no casting it works:

a <- as.ffdf(data.frame(matrix(rnorm(10),ncol=2)))
b <- as.ffdf(data.frame(matrix(rnorm(10),ncol=2)))

colnames(a) <- 1:2
colnames(b) <- 3:4

a$RN <- as.ff(1:5)
b$RN <- as.ff(1:5)


c <- merge(a,b,by="RN")
1

There are 1 answers

0
AudioBubble On

Interesting. merge.ffdf is part of ffbase so this should work but apparently when doing ffbase:::as.ff_matrix.ffdf, PhysicalIsMatrix is still TRUE. This might mess up the generic dispatching.

ffdf (all open) dim=c(5,3), dimorder=c(1,2) row.names=NULL
ffdf virtual mapping
   PhysicalName VirtualVmode PhysicalVmode  AsIs VirtualIsMatrix PhysicalIsMatrix PhysicalElementNo PhysicalFirstCol PhysicalLastCol PhysicalIsOpen
1             x       double        double FALSE           FALSE             TRUE                 1                1               1           TRUE
2             x       double        double FALSE           FALSE             TRUE                 1                2               2           TRUE
RN           RN      integer       integer FALSE           FALSE            FALSE                 2                1               1           TRUE

Can you report this at https://github.com/edwindj/ffbase/issues. I'll have a look to see if I can change the unexported ffbase:::as.ff_matrix.ffdf. Thanks.