-
Notifications
You must be signed in to change notification settings - Fork 993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to print the number of columns #6663
Comments
Closing, this should go in #1523 |
Re-opened -- #1523 is more of an umbrella issue. I think this will keep more attention as a standalone issue. I think it's a good idea -- it can be hard to tell the exact number of columns on tables that require wrapping, especially multiple times. Perhaps the row with OTOH,
No, Most important will be the interaction with
@TysonStanley WDYT about something like:
That would mean moving the note from the footer to the header. |
Imho for coherence, the output should be similar to: print(data.table(a=integer(0)))
# Empty data.table (0 rows and 1 cols): a
print(data.table())
# Null data.table (0 rows and 0 cols) |
Agree! I'm not proposing any changes to those current messages. |
ITMT: # install.packages("devtools")
devtools::install_github("KyleHaynes/data.table", build_vignettes=FALSE, ref="print_col_nums")
require(data.table)
dt = data.table(iris)
dt
# Number of columns: 5
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# <num> <num> <num> <num> <fctr>
# 1: 5.1 3.5 1.4 0.2 setosa
# 2: 4.9 3.0 1.4 0.2 setosa
# 3: 4.7 3.2 1.3 0.2 setosa
# 4: 4.6 3.1 1.5 0.2 setosa
# 5: 5.0 3.6 1.4 0.2 setosa
# ---
# 146: 6.7 3.0 5.2 2.3 virginica
# 147: 6.3 2.5 5.0 1.9 virginica
# 148: 6.5 3.0 5.2 2.0 virginica
# 149: 6.2 3.4 5.4 2.3 virginica
# 150: 5.9 3.0 5.1 1.8 virginica
setkey(dt)
setindex(dt,Species,Sepal.Width)
dt
# Key: <Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species>
# Index: <Species__Sepal.Width>
# Number of columns: 5
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# <num> <num> <num> <num> <fctr>
# 1: 4.3 3.0 1.1 0.1 setosa
# 2: 4.4 2.9 1.4 0.2 setosa
# 3: 4.4 3.0 1.3 0.2 setosa
# 4: 4.4 3.2 1.3 0.2 setosa
# 5: 4.5 2.3 1.3 0.3 setosa
# ---
# 146: 7.7 2.6 6.9 2.3 virginica
# 147: 7.7 2.8 6.7 2.0 virginica
# 148: 7.7 3.0 6.1 2.3 virginica
# 149: 7.7 3.8 6.7 2.2 virginica
# 150: 7.9 3.8 6.4 2.0 virginica
data.table()
# Null data.table (0 rows and 0 cols)
data.table(as.character())
# Empty data.table (0 rows and 1 cols): V1
options(width=10)
print(dt, trunc.cols=TRUE)
# Key: <Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species>
# Index: <Species__Sepal.Width>
# Number of columns: 5, of which 5 are not shown: [Sepal.Length <num>, Sepal.Width <num>, Petal.Length <num>, Petal.Width <num>, Species <fctr>]
options(width=200)
options("datatable.show.ncols" = FALSE)
# Key: <Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species>
# Index: <Species__Sepal.Width>
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# <num> <num> <num> <num> <fctr>
# 1: 4.3 3.0 1.1 0.1 setosa
# 2: 4.4 2.9 1.4 0.2 setosa
# 3: 4.4 3.0 1.3 0.2 setosa
# 4: 4.4 3.2 1.3 0.2 setosa
# 5: 4.5 2.3 1.3 0.3 setosa
# ---
# 146: 7.7 2.6 6.9 2.3 virginica
# 147: 7.7 2.8 6.7 2.0 virginica
# 148: 7.7 3.0 6.1 2.3 virginica
# 149: 7.7 3.8 6.7 2.2 virginica
# 150: 7.9 3.8 6.4 2.0 virginica
|
Could
data.table:::print.data.table
look to gain an option to print the number of columns?Happy to put a PR in if so.
If yes, things to consider
ncols
to matchnrows
?)getOption("datatable.print.ncols")
ncol
)print.data.table
already communicates this)e.g.
The text was updated successfully, but these errors were encountered: