[datatable-help] unname does not work with data.table anymore

Christoph Jäckel christoph.jaeckel at wi.tum.de
Sat Mar 31 15:33:49 CEST 2012


Hi together,

I'm really sorry for bothering again and please let me know if I should
just raise bug reports, but I understand far too less about R and
data.table to know whether or not the error messages I stumble across are
due to deliberate changes in v1.8.0 or just minor bugs that were introduced
by that version.

Here is another one that I discovered while running old code that melted
(plyr-package) a data.table. In that melt-function, unname() is called,
which does not work anymore with v1.8.0:

library(data.table)
DT <- data.table(A = rep(letters[1:10], each=5),
                 B = rep(1:10, times=5),
                 C = rnorm(50))
unname(DT)

Error message:

Error in setnames(x, value) :
  Can't assign 0 names to a 3 column data.table


Checking out the source of unname, it's the following row that causes
the problems:

names(DT) <- NULL


So I guess it's the old issue with the copying of data.tables, which
is why data.table introduced setnames(). Just out of curiosity: How
can one fix that? Apparently, unname is a base-R function that uses
names(DT), but data.tables do not like that? So what can one do? Can
one overload such base-R functions?

Anyways, I hope that minimal example helps. Again, if I should raise a
bug report, just let me know.

Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20120331/fe05c08b/attachment.html>


More information about the datatable-help mailing list