[Bioc-devel] cbind for DataFrame no longer behaving as expected

Michael Lawrence lawrence.michael at gene.com
Fri Sep 8 17:41:24 CEST 2017

This is a problem with DataFrame(). Base R's data.frame uses
as.data.frame() to coerce its arguments, passing optional=TRUE. With
optional=TRUE, vectors and other things without column names coerced
to data.frames will have NULL names, so data.frame() can tell the
difference between real/original names and concocted names, for which
it uses the argument name or the deparsed argument as a last resort.
Since DataFrame does not support NULL names, we have long relied on a
heuristic that breaks in this case:

> DataFrame(list(data.frame(foo=1)))
1                         1

> data.frame(list(data.frame(foo=1)))
1   1

I will fix this somehow. Btw, you can submit these types of issues
through github now.


On Fri, Sep 8, 2017 at 6:25 AM, Aaron Lun <alun at wehi.edu.au> wrote:
> Dear list,
> It seems that an alteration to the cbind method for DataFrame objects in S4Vectors (probably d595a19b19df9b9c9aaef71e9c1cd1bdc681bfb1) has led to some strange behaviour. In particular, if I run this code with S4Vectors 0.15.7, I get the following output:
> require(S4Vectors)
> cbind(DataFrame(score=1, xxx=1), DataFrame(row.names=1)) # okay
> ## DataFrame with 1 row and 2 columns
> ##      score       xxx
> ##  <numeric> <numeric>
> ## 1         1         1
> cbind(DataFrame(score=1), DataFrame(row.names=1)) # strange
> ## DataFrame with 1 row and 1 column
> ##        dfs
> ##  <numeric>
> ## 1         1
> The first cbind() call works as expected, but the named "score" field disappears in the output object of the second cbind() call, which is rather surprising. This is the source of at least a few failed tests in the InteractionSet package.
> Cheers,
> Aaron
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel

More information about the Bioc-devel mailing list