Skip to content
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

Case for replacement acting as ifelse() ? #23

Open
karoliskoncevicius opened this issue Oct 31, 2019 · 4 comments
Open

Case for replacement acting as ifelse() ? #23

karoliskoncevicius opened this issue Oct 31, 2019 · 4 comments

Comments

@karoliskoncevicius
Copy link
Collaborator

While adding examples for replacement operators, I badly wanted to do this:

cars <- rownames(mtcars)
cars %in~% "^Mazda" <- toupper(cars)

Instead of a more elaborate

cars %in~% "^Mazda" <- toupper(cars %[in~% "^Mazda"% )

But on the other hand - this might be a bit confusing. @moodymudskipper what do you think?

@moodymudskipper
Copy link
Owner

I had the same dilemma when deciding how to code :

cars %in~% "^Mazda" <- toupper
cars %in~% "^Mazda" <- ~ toupper(.)

I think your syntax would be confusing and complexity code that is nicely compact and understandable (easy to investigate from users if edge cases).

Even with my function/formula syntax I think there were caveats that made me decide against it but I m not sure and don't remember which.

We could reintroduce the function notation with your proposed behavior and play with it to see what goes wrong if you want

@moodymudskipper
Copy link
Owner

If think one case against it was : what if I want to replace missing values by the average?

@karoliskoncevicius
Copy link
Collaborator Author

I see. We probably better leave this for the future.

But one related thing is - what is our strategy with multi-value assignments? Related issue #21

@moodymudskipper
Copy link
Owner

We might use the formula notation with .x for lhs and .y for subset but now it starts to be confusing again :)

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

No branches or pull requests

2 participants