-
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
Add setdroplevels() to replace droplevels(in.place=TRUE) #6014
Comments
Hi i was going through this issue and want to work on it, and i noticed that we only have to replace
and setup the setdroplevels for only doing the inplace modifications. alternatively we can also try
|
Not error but warning, at most |
so |
Or, first a message, then in next release cycle a warning. |
I like the principle (limiting in-place operations to Having the function be called |
@jangorecki @MichaelChirico Hi, i was implementing the
but despite being identical to each other, while doing some operation like
I am confused about , why is this happening?, and tried searching online but wasn't successful in finding anything useful there either. |
@Nj221102 The droplevels call isn't using droplevels.data.table(). |
See also #2219. I would be a fan of setlevels(x, levels) # provide a vector of levels
setlevels(x, drop=TRUE) # equivalent to droplevels(x, in.place=TRUE)
setlevels(x, levels, drop) # error, I think? Actually, to get closer to |
Wouldn't it be cleaner/more equivalent to common R setting to just use setlevels(x, levels)
setlevels(x, levels=NULL) # to droplevels |
I m bit confused, like if |
You should check out how method dispatch is working in R especially S3 classes. You are calling droplevels on a vector and hence it is dispatched to the default method |
I don't like this, I think it's trying to be too cute & overload the signature. Adding a new argument will make for more readable code.
Re-read |
Honestly I'm not that worried about this. We already have |
Originally posted by @jangorecki in #5907 (comment)
We'll need to go through a deprecation cycle for
droplevels(in.place=TRUE)
, but we should return to the principle that onlyset*
functions and:=
can do in-place modification.Luckily, I don't see any usage of this on GitHub, so we don't need to worry too much about breaking downstreams:
https://github.com/search?q=lang%3AR+%2Fdroplevels%5B%28%5D%2F+%2Fin%5B.%5Dplace%5Cs*%3D%2F+-path%3Afdroplevels.R&type=code
Therefore I recommend we start the deprecation cycle in 1.16.0.
The text was updated successfully, but these errors were encountered: