Skip to content

add sort_by.data.table #6679

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
merged 12 commits into from
Feb 25, 2025
Merged

add sort_by.data.table #6679

merged 12 commits into from
Feb 25, 2025

Conversation

rikivillalba
Copy link
Contributor

@rikivillalba rikivillalba commented Dec 21, 2024

Proposal for #6662

  • Note that sort_by.data.table() will sort using C-locale now, this is incompatible with base::sort_by.data.frame() used on data.tables

Copy link

github-actions bot commented Dec 21, 2024

Comparison Plot

Generated via commit ee44ef4

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 4 minutes and 34 seconds
Installing different package versions 8 minutes and 18 seconds
Running and plotting the test cases 2 minutes and 22 seconds

Copy link
Member

@MichaelChirico MichaelChirico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I think it needs an entry in man/, probably in ?forder would be the most logical place?

@rikivillalba
Copy link
Contributor Author

Looks good! I think it needs an entry in man/, probably in ?forder would be the most logical place?

Added a reference in setorder.Rd (?forder). PTAL.

man/setorder.Rd Outdated
@@ -32,6 +33,7 @@ setorderv(x, cols = colnames(x), order=1L, na.last=FALSE)
# optimised to use data.table's internal fast order
# x[order(., na.last=TRUE)]
# x[order(., decreasing=TRUE)]
# sort_by(x, ., na.last=TRUE, decreasing=FALSE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMIIW, we leave this as a comment instead of \method{sort_by}{data.table} because the method is not available in all supported R versions, is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello. I simply put another use case, these are provided as comments and printed verbatim (as comments) in manpages.
However now that you mention this, I clarified that those references to sort_by are only R>=4.4.0

@MichaelChirico
Copy link
Member

Ah, unfortunately because of r-lib/covr#567 we won't get coverage of this code yet -- the coverage runner is stuck on an R version before sort_by() is available.

Copy link
Member

@MichaelChirico MichaelChirico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still unsure if we should try something to ensure \method{sort_by}{data.table}(x, \dots) is used "properly", but anyway LGTM, thanks!!

@MichaelChirico
Copy link
Member

MichaelChirico commented Feb 25, 2025

I noticed {maditr} also defines S3method(sort_by,data.table):

https://github.com/gdemin/maditr/blob/a4df8cccfe5ca5c8a919c6b6be2eb0e238c8866b/NAMESPACE#L19

cc @gdemin

I suppose that will cause breakage on release.

Anyway, there the \method{sort_by}{data.table} exists:

https://github.com/gdemin/maditr/blob/a4df8cccfe5ca5c8a919c6b6be2eb0e238c8866b/man/let_if.Rd#L27

Copy link

codecov bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 98.60%. Comparing base (5a04ba8) to head (ee44ef4).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
R/data.table.R 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6679      +/-   ##
==========================================
- Coverage   98.64%   98.60%   -0.05%     
==========================================
  Files          79       79              
  Lines       14650    14656       +6     
==========================================
  Hits        14452    14452              
- Misses        198      204       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MichaelChirico MichaelChirico merged commit 3aee430 into master Feb 25, 2025
8 of 9 checks passed
@MichaelChirico MichaelChirico deleted the sort_by.data.table branch February 25, 2025 19:35
@aitap
Copy link
Contributor

aitap commented Feb 25, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants