x=data.table(1)[0] # an empty data.table
Typing x on its own calls the data.table print method:
> x
Empty data.table (0 rows) of 1 col: V1
Typing print(x) should give the same result as above, however there is extra output:
> print(x)
Empty data.table (0 rows) of 1 col: V1
NULL
Very low priority I guess, but a bug nonetheless (I think).
I think it's because, in such cases, the return statement (within the code for data.table:::print.data.table) is as follows:
However, it should return invisibly, as expected by the ?print documentation
‘print’ prints its argument and returns it invisibly (via
‘invisible(x)’).
The method should return the value (not NULL) and it should return invisibly. Something like:
Typing
xon its own calls the data.table print method:Typing
print(x)should give the same result as above, however there is extra output:Very low priority I guess, but a bug nonetheless (I think).
I think it's because, in such cases, the return statement (within the code for
data.table:::print.data.table) is as follows:However, it should return invisibly, as expected by the
?printdocumentationThe method should return the value (not
NULL) and it should return invisibly. Something like: