-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fast droplevels.data.table #5116
Conversation
Benchmarks comparing to as_factor = data.table:::as_factor
N=1e5
x=as_factor(paste0("id",1:N))
y1 = sample(x, N/10)
c1 = as.character(y1)
microbenchmark(times = 10L,
droplevels(y1),
factor(y1),
as_factor(c1),
fdroplevels(y1)
)
|
NAMESPACE
Outdated
@@ -58,6 +58,8 @@ export(.Last.updated) | |||
export(fcoalesce) | |||
export(substitute2) | |||
export(DT) # mtcars |> DT(i,j,by) #4872 | |||
export(fdroplevels) | |||
export(droplevels) |
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.
as droplevels
is in base and generic, all we need, iiuc, is the S3method
line below you've got already. Putting export(droplevels)
here as well will generate a warning on loading the package that droplevels
is masked? But I'm writing from memory so I might have that wrong.
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.
I see and did not notice before because no warning was generated. According to Writing R Extensions putting export(droplevels)
is not necessary but possible.
Example:
S3method(print, foo)
Since the generic print is defined inbase
it does not need to be imported explicitly.
I removed it now.
Codecov Report
@@ Coverage Diff @@
## master #5116 +/- ##
=======================================
Coverage 99.38% 99.38%
=======================================
Files 76 77 +1
Lines 14489 14506 +17
=======================================
+ Hits 14400 14417 +17
Misses 89 89
Continue to review full report at Codecov.
|
Hi @mattdowle and @ben-schwen Thank you for this new function.
|
@Kamgang-B
|
@ben-schwen thanks for your reply. |
Closes #647
fdroplevels
forfactor
sdata.table
(based on Jan's initial proposal but withexclude
argument asdata.frame
)