-
Notifications
You must be signed in to change notification settings - Fork 0
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
multiple replacements #43
Comments
I think this is much needed functionality, I was using this package for my work on the weekend and was missing it at least a few times. Also one person on your twitter post (which was very nice by the way, we got a great reception!) left this:
Which in my mind was hinting at the same thing. |
Is it normal to have 3 elements in value and 4 in range here ?
It seems to me you want to have the range argument mean something different depending on the class of the If so I'm afraid this will be a big source a confusion, though I guess it could technically work. In For intervals I suggested this :
Or
But I really think I see potential value in a family of functions to recode based on sets, ranges, regex or counts, but Here are some ideas for a
Maybe I still don't understand your use cases. Can you come up with a draft of one of those functions |
The example was in particular constructed so that it is consistent with
Yes, very good point. If this would get long enough it would be a bit burdensome to track which range is related to which value.
My main wish is precisely as you stated in the previous sentence - to reduce the cognitive load. I would much prefer to have one way of replacing working for both scenarios, not needing to remember different functions for all exceptions. The problem I see currently, which I tried to describe in the first post too, is that when using the package I very rarely want to only replace one value with another. Multiple replacements seem to be much more common. Hence the replacement operators we have are not really useful for this, and it will almost always be better to do
I do think it's more verbose by a little bit - repeating variable and comparison operators:
But yes, |
I think understand better, I agree that no existing solution feels perfectly right, and that our package feels like it might offer a bridge to something nicer. In particular I don't know any approach that solves the awkwardness of the fact that we have one less interval than breakpoints. I also like the idea of a generalized approach to recoding and cutting, incl regex support. I'm just not very comfortable with complexifying the existing functions, and I feel your proposed syntax is problematic for reasons given above. This might need to be a new family of functions with different consistency rules, but by all means if you really feel that your proposed syntax can be intuitive and useful let's try it. |
I think this is because you are used to those numbers being break points, while in this example they are intervals - since we might not want to replace the whole range of values, but only a subset. In particular:
If instead the whole range of x needs to be divided into categories:
Basically think "between the values" - to me it's more intuitive than break points for some reason. Also it is consistent with Regarding the syntax - I agree, will think more about it, see if something "pops up" to mind. |
This issue again :) But I think I have a proposal that might actually work, unless I am missing something.
In short, replacing multiple values at once would be a nice step, especially when:
numerics are replaced with characters
regex replacements overlap with new checks
counts will change and overlap
To overcome these - a syntax allowing to replace multiple values at once would help. My suggestion, that I wish to get some feedback on is to do this if rhs is a
list
:Of course it's a bit tricky how this would work with
%out%
- at least might be non-intuitive, but probably would be included for consistency.@moodymudskipper what do you think?
The text was updated successfully, but these errors were encountered: