[datatable-help] Assignment by reference fails silently

John Laing john.laing at gmail.com
Fri Apr 25 19:25:13 CEST 2014


If I create a logical column in my data.table and try to
assign-by-reference a character value to it, the assignment fails silently.
That is, it doesn't work but doesn't throw an error:

## make a simple data.table
require(data.table)
dt <- data.table(a=1:3, b=4:6, c=NA)

## fails silently
dt[, c := "foo"]
dt

In other cases where an action would lead to the implicit conversion of a
column, data.table throws an error suggesting that the user convert the
column explicitly if that's what they really mean to do. I think that's the
right behavior and should be adopted in this case as well.

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


More information about the datatable-help mailing list