Update:
The fix has just been merged in v1.10.5. Thanks to Michael Chirico.
After launch:
install.packages('data.table', type = 'source', repos = 'http://Rdatatable.imtqy.com/data.table')
It will work as expected:
library(data.table)
Perhaps this is due to the fact that the print method for data.table does the wrong thing. Printing methods are expected to be invisible. But I suspect that data.table:::print.data.table returning noticeably.
(Update: I just sent an error report to data.table . I apologize to them if I analyzed it incorrectly!)
From ?print :
'prints its argument and returns it invisibly (via "invisible (x)).
Here is a tiny demonstration of what might happen:
> x=list() > class(x) <- 'X' > print.X <- function(x) { print("I am printing"); return(1729); } > x [1] "I am printing" > print(x) [1] "I am printing" [1] 1729
Note that typing x by itself simply prints text, but not a number. But by typing print(x) , you can also print the number.
Then, if I arrange for this printing method to return invisibly as follows:
> print.X <- function(x) { print("I am printing"); return(invisible(1729)); }
.. then print(x) gives the expected output
> print(x) [1] "I am printing"
So, when you type x on the console, the console calls print on your behalf and ignores the return value from print (which may be visible). But if you type print(x) , then the return value of print will be printed if it is visible.
The documentation ?print bit wrong, I think. The print methods are supposed to return their argument and should do this invisibly, but these rules do not apply.