-
Notifications
You must be signed in to change notification settings - Fork 1k
Ensure Consistent Key Handling in as.data.table S3 Methods #6865
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
Merged
ben-schwen
merged 21 commits into
Rdatatable:master
from
Mukulyadav2004:fix_key_inconsistency
Mar 17, 2025
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
55a6e14
fixing key setting order
Mukulyadav2004 22672c1
fix key setting order
Mukulyadav2004 158b833
document argument keep.rownames and key
Mukulyadav2004 826260a
add tests and news.md
Mukulyadav2004 d73f405
add rownames and key in .Rd
Mukulyadav2004 ede931e
Extract keep.rownames and key from ...
Mukulyadav2004 95f0deb
eliminate %>% operator
Mukulyadav2004 8a16565
update test 2309.2
Mukulyadav2004 bc00de6
update tests
Mukulyadav2004 c4fcff4
set key
Mukulyadav2004 5ca34a7
update key handling
Mukulyadav2004 f404b02
update test
Mukulyadav2004 27bc253
corrected last test
Mukulyadav2004 83dee96
correct test case
Mukulyadav2004 2583d6e
correct 2309.04
Mukulyadav2004 0269583
update fix
Mukulyadav2004 bf0db0c
update changes
Mukulyadav2004 1863bc9
Update R/as.data.table.R
ben-schwen 8e2a2b3
Update R/as.data.table.R
ben-schwen fa495d5
update tests
Mukulyadav2004 c31d1e7
correct signature of as.data.table.data.table
Mukulyadav2004 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21084,3 +21084,23 @@ test(2307, { capture.output(print(DT, class = TRUE, show.indices = TRUE)); TRUE | |
| dt = data.table(date=as.IDate(c(NA, "2014-12-05"))) | ||
| test(2308.01, fread("date\nNA\n2014-12-05", keepLeadingZeros=TRUE), dt) | ||
| test(2308.02, fread("date\nNA\n2014-12-05", keepLeadingZeros=FALSE), dt) | ||
|
|
||
| # Test that as.data.table.data.table preserves key when explicitly specified but not when omitted | ||
| DF = data.frame(t = c(3:1, 4:5), y = 1:5) | ||
| # data.frame to data.table with key | ||
| test(2309.01, key(as.data.table(DF, key="t")), "t") | ||
| # tibble to data.table with key | ||
| class(DF) = c("tbl_df", "tbl", "data.frame") | ||
| test(2309.02, key(as.data.table(DF, key="t")), "t") | ||
ben-schwen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # data.table keyed with "b" | ||
| DT = data.table(a = 1:5, b = 1:5, x = 1:5, key = "b") | ||
| test(2309.03, key(as.data.table(DT, key="a")), "a") | ||
| test(2309.04, key(as.data.table(DT)), "b") | ||
| test(2309.05, key(as.data.table(DT, key=NULL)), NULL) | ||
|
|
||
|
||
| # non-keyed data.table | ||
| DT = data.table(a = 1:5, b = 1:5, x = 1:5) | ||
| test(2309.06, key(as.data.table(DT, key="a")), "a") | ||
| test(2309.07, key(as.data.table(DT)), NULL) | ||
| test(2309.08, key(as.data.table(DT, key=NULL)), NULL) | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.