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

Matthew Dowle mdowle at mdowle.plus.com
Mon Apr 2 01:53:26 CEST 2012


No problem at all, this is what the list is for.

Fixed now in v1.8.1 :

o base::unname(DT) now works again, as needed by plyr::melt(). Thanks to
  Christoph Jaeckel for reporting. Test added.


On Sat, 2012-03-31 at 15:33 +0200, Christoph Jäckel wrote:
> 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 
> 
> 
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help




More information about the datatable-help mailing list