Skip to content

[REQUEST] Print only first/last few columns #2608

@vlulla

Description

@vlulla

I regularly use fread to read csv files which have hundreds of columns. For cursory exploration I just print the name of the variable to see what it contains and it will print all the columns! This makes it difficult to glance wide data. Census bureau demographic files are an example of wide data format that I commonly use.

Is it possible to modify the print.data.table function to show only first/last few columns instead of all the columns? data.table already does this for rows where only the first/last few (controlled by options variables) rows are shown with the intermediate rows represented as ---. But there is nothing analogous for columns. A tibble gets around this problem by printing the dimensions of the tibble first and then printing only the first 10 rows with a few columns and then listing just the column names. Julia language does this even better, but primarily for matrices. Try randn(150,150) in a julia repl to see what I mean.

Additionally, is it possible to list the dimension of data.table just like tibbles? If this suggestion appears too unfavorable (I too am not convinced that this works best for data.table) the column number might be listed as a suffix to the column datatype which is controlled by the datatable.print.class option variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions