-
Notifications
You must be signed in to change notification settings - Fork 1k
Adds optional column count display to print.data.table()
#7791
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
Open
venom1204
wants to merge
23
commits into
master
Choose a base branch
from
issue6663
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e7e92b1
added changes
venom1204 021d6e2
..
venom1204 864954e
added test
venom1204 1850b39
added doc
venom1204 78621eb
..
venom1204 2aec2a5
..
venom1204 3e58a32
removed empty lines
venom1204 43dddf2
added news
venom1204 d638819
Merge remote-tracking branch 'origin/master' into issue6663
venom1204 aa54da6
updated tests
venom1204 d4d80f1
.
venom1204 0c69365
..
venom1204 6757317
added test
venom1204 e697d45
test
venom1204 61368bf
Merge remote-tracking branch 'origin/master' into issue6663
venom1204 d21225b
..
venom1204 4bc39fc
updated version
venom1204 e908057
Merge branch 'master' into issue6663
ben-schwen beb43fa
updated logic and added test
venom1204 3e38a5b
Merge remote-tracking branch 'origin/master' into issue6663
venom1204 84c707b
updated logic
venom1204 a8d3284
...
venom1204 fbe05f3
Merge branch 'master' into issue6663
ben-schwen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21797,3 +21797,14 @@ test(2378.92, .Call(CresizeVector, x, 2:3), error = "must be length 1 non-NA non | |
| test(2378.93, .Call(CresizeVector, x, -2L), error = "must be length 1 non-NA non-negative integer value") | ||
| test(2378.94, .Call(CresizeVector, x, NA_integer_), error = "must be length 1 non-NA non-negative integer value") | ||
| test(2378.95, .Call(CresizeVector, NULL, 2L), error = "must be a vector") | ||
|
|
||
| #6663 Option to print the number of columns | ||
| test(2379.1, print(as.data.table(iris)), output="Number of columns: 5", options=list(datatable.show.ncols=TRUE)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as in other PR, do we really need the |
||
| test(2379.2, print(setkey(as.data.table(iris), Sepal.Length)), output="Number of columns: 5", options=list(datatable.show.ncols=TRUE)) | ||
| test(2379.3, { dt = data.table(a=1:3, b=1:3, c=1:3, d=1:3, e=1:3); any(grepl("^[0-9]+ variables? not shown", capture.output(print(dt, trunc.cols=TRUE)))) }, FALSE, options=list(width=20, datatable.show.ncols=TRUE)) | ||
| test(2379.4, print(as.data.table(iris), trunc.cols=TRUE), output="Number of columns: 5, of which 5 are not shown: [Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species]", options=list(width=10, datatable.show.ncols=TRUE)) | ||
| test(2379.5, any(grepl("Number of columns:", capture.output(print(as.data.table(iris))))), FALSE, options=list(datatable.show.ncols=FALSE)) | ||
| test(2379.6, print(as.data.table(iris), trunc.cols=TRUE, class=TRUE), output="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=list(width=10, datatable.show.ncols=TRUE)) | ||
| test(2379.7, { dt = data.table(matrix(1:200, nrow=25)); out = capture.output(print(dt, trunc.cols=TRUE, class=TRUE)); grepl("<int>", out[length(out)]) }, TRUE, options=list(width=30, datatable.show.ncols=TRUE)) | ||
| test(2379.8, any(grepl("variable", capture.output(print(data.table(a=1), trunc.cols=TRUE)))), FALSE, options=list(width=80, datatable.show.ncols=FALSE)) | ||
| test(2379.9, print(setindex(data.table(a=1:2, b=3:4), a), show.ncols=TRUE, show.indices=TRUE), output="Number of columns: 2") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| print.keys=getOption("datatable.print.keys"), # default: TRUE | ||
| trunc.cols=getOption("datatable.print.trunc.cols"), # default: FALSE | ||
| show.indices=getOption("datatable.show.indices"), # default: FALSE | ||
| show.ncols=getOption("datatable.show.ncols", FALSE), # default: FALSE | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to pass default when we set onLoad? |
||
| quote=FALSE, | ||
| na.print=NULL, | ||
| timezone=FALSE, \dots) | ||
|
|
@@ -44,6 +45,7 @@ | |
| \item{trunc.char}{The number of characters at which character columns and list-column summaries are truncated. If \code{NULL} (the default), it is dynamically calculated based on \code{getOption("width")}.} | ||
| \item{class}{ If \code{TRUE}, the resulting output will include above each column its storage class (or a self-evident abbreviation thereof). When combined with \code{col.names="auto"} and tables >20 rows, classes will also appear at the bottom.} | ||
| \item{row.names}{ If \code{TRUE}, row indices will be printed alongside \code{x}. } | ||
| \item{show.ncols}{ If \code{TRUE}, the number of columns is printed in the header. } | ||
| \item{col.names}{ One of three flavours for controlling the display of column names in output. \code{"auto"} includes column names above the data, as well as below the table if \code{nrow(x) > 20} (when \code{class=TRUE}, column classes will also appear at the bottom). \code{"top"} excludes this lower register when applicable, and \code{"none"} suppresses column names altogether (as well as column classes if \code{class = TRUE}. } | ||
| \item{print.keys}{ If \code{TRUE}, any \code{\link{key}} and/or \code{\link[=indices]{index}} currently assigned to \code{x} will be printed prior to the preview of the data. } | ||
| \item{trunc.cols}{ If \code{TRUE}, only the columns that can be printed in the console without wrapping the columns to new lines will be printed (similar to \code{tibbles}). } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The column count seems to be wrong when using
show.indices=TRUE