edwindj / ffbase

Basic (statistical) functionality for R package ff
github.com/edwindj/ffbase/wiki
35 stars 15 forks source link

Unclear error when calling rbind.ffdf() on ffdf with different number of columns #12

Closed nalimilan closed 11 years ago

nalimilan commented 11 years ago
library(ffbase)
a <- as.ffd(data.frame(a=1:10, b=1:10))
b <- as.ffdf(data.frame(a=1:10, b=1:10, c=1:10))

rbind(a, b)
Error in data.frame(x.vmode = vmode(x), y.vmode = vmode(y), stringsAsFactors = FALSE) : 
  arguments imply different number of rows : 2, 3
In addition: Warning:
In ffdfappend(x, l) : names not identical when appending through ffdfappend

This error message is really misleading as it mentions rows while the number of columns differs between the two ffdf.

nalimilan commented 10 years ago

Sorry, this does not seem to be completely fixed. With a slightly different test case, I still get a weird error:

> iris1 <- as.ffdf(iris)
> iris2 <- as.ffdf(iris)
> rbind(iris1, subset(iris2, select=Species))
Erreur dans .subset2(dummy, i, exact = exact) : index out of bounds
> traceback()
9: `[[.ffdf`(dat, i)
8: dat[[i]]
7: lapply(list(...), function(x) {
       if (is.factor(x)) 
           levels(x)
       else x
   })
6: unlist(lapply(list(...), function(x) {
       if (is.factor(x)) 
           levels(x)
       else x
   }))
5: unique(unlist(lapply(list(...), function(x) {
       if (is.factor(x)) 
           levels(x)
       else x
   })))
4: appendLevels(levels(x[[i]]), dat[[i]])
3: ffdfappend(x, l)
2: rbind(deparse.level, ...)
1: rbind(iris1, subset(iris2, select = Species))

> ffdfappend(iris1, subset(iris2, select=Species))
Erreur dans .subset2(dummy, i, exact = exact) : index out of bounds

Also, with the test case of the original description, there are additional warnings that are not really useful:

a <- as.ffdf(data.frame(a=1:10, b=1:10))
b <- as.ffdf(data.frame(a=1:10, b=1:10, c=1:10))
> rbind(a, b)
Erreur dans ffdfappend(x, l) : Number of columns does not match
In addition: Warnings
1: In fc | sapply(physical(x), is.factor.ff) :
  size of a longer object is not a multiple of that of a shorter object [approximate translation]