Various enhancements to print.data.table
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reviewing the remaining unchecked items in this issue and the existing print.data.table documentation, including the .Rd file and the man-page work associated with PR #1448. Check the linked historical references and comments to determine which requests are still in scope. Done requires an agreed, testable subset of enhancements rather than the entire mixed task list.
Written by the indexing model from the issue text.
Description
Current task list:
- Add
.Rdfile forprint.data.table| 045ba8a3f13f10490afc15cc2a3316854eb0425c - #645 | Ability to turn off row numbers
ac2180ef17b8a46245261349f05f5967318407cf #645 | Ability to turn off smart table wrapping- #645 | Ability to force-print all entries | a82bfff820d77fbb7ba445e65972e059e036f5150
- #645 | Ability to demarcate
by-groupings - #645 | Demarcation of table border
#645 | Demarcation of key columns- #1097 | #1570
- #1482 | #2296
- Option for
dplyr-like printing [see below] - #1497 | #2608 | #4074
- #1374
- #545 #1574
- #605 | #2562
- #2482
- #4074
- #6663
Some Notes
3 (tabled pending clarification)
As I understand it, this issue is a request to prevent the console output from wrapping around (i.e., to force all columns to appear parallel, regardless of how wide the table is).
If that's the case, this is (AFAICT) impossible, since that's something done by RStudio/R itself. I for one certainly don't know of any way to alter this behavior.
If someone does know of a way to affect this, or if they think I'm mis-interpreting, please pipe up and we can have this taken care of.
7
As I see it there are two options here. One is to treat all key columns the same; the other is to treat secondary, tertiary, etc. keys separately.
Example output:
set.seed(01394)
DT <- data.table(key1 = rep(c("A","B"), each = 4),
key2 = rep(c("a","b"), 4),
V1 = nrorm(8), key = c("key1","key2"))
# Only demarcate key columns
DT
# | key1 | | key2 | V1
#1: | A | | a | 0.5994579
#2: | A | | a | -1.0898775
#3: | A | | b | -0.2285326
#4: | A | | b | -1.7858472
#5: | B | | a | -0.6269875
#6: | B | | a | -0.6633084
#7: | B | | b | 1.0367084
#8: | B | | b | 0.7364276
# Separately "emboss" keys based on key order
DT
# | key1 | || key2 || V1
#1: | A | || a || 0.5994579
#2: | A | || a || -1.0898775
#3: | A | || b || -0.2285326
#4: | A | || b || -1.7858472
#5: | B | || a || -0.6269875
#6: | B | || a || -0.6633084
#7: | B | || b || 1.0367084
#8: | B | || b || 0.7364276
And of course, add an option for deciding whether to demarcate with | or some other user's-choice character (*, +, etc.)
9 [DONE]
Some feedback from a closed PR that was a first stab at solving this:
From Arun regarding preferred options:
col.names = c("auto", "top", "none")
"auto": current behaviour
"top": only on top,data.frame-like
"none": no column names -- exclude rows in which column names would have been printed.
10 [DONE]
It would be nice to have an option to print a row under the row of column names which gives each column's stored type, as is currently (I understand) the default for the output of dplyr operations.
Example from dplyr:
library(dplyr)
DF <- data.frame(n = numeric(1), c1 = complex(1), i = integer(1),
f = factor(1), D = as.Date("2016-02-06"), c2 = character(1),
stringsAsFactors = FALSE)
tbl_df(DF)
# Source: local data frame [1 x 6]
#
# n c1 i f D c2
# (dbl) (cmpl) (int) (fctr) (date) (chr) # <- this row
#1 0 0+0i 0 1 2016-02-06
Current best alternative is to do sapply(DF, class), but it's nice to have a preview of the data wit this extra information.
11
This seems closely related to 3. Current plan is to implement this as an alternative to 3 since it seems more tangible/doable.
Via @nverno:
Would it be useful for
head.data.tableto have an option to print only the head of columns that fit the screen width, and summarise the rest? I was imagining something like the printed output from the head of atbl_dfindplyr. I think it is nice for tables with many columns.
and the guiding example from Arun:
require(data.table)
dt = setDT(lapply(1:100, function(x) 1:3))
dt
dplyr::tbl_dt(dt)
12
Currently covered by @jangorecki's PR #1448; Jan, assuming #1529 is merged first, could you edit the print.data.table man page for your PR?
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·