Skip to content

data.table:::print.data.table sometimes returns visibly, however it should be invisible #1852

@aaronmcdaid

Description

@aaronmcdaid
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:

return()

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:

return(invisible(x))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions