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

Could select() substitute mutate() to add new variable? #355

Closed
yanlinlin82 opened this issue Mar 26, 2014 · 2 comments
Closed

Could select() substitute mutate() to add new variable? #355

yanlinlin82 opened this issue Mar 26, 2014 · 2 comments

Comments

@yanlinlin82
Copy link

I guess this habit should come from the SQL thinking.

When I occasionally tried the following code:

data.frame(A = 1:3, B = 2:4) %.% select(C = A + B)
in which case the code should be:
data.frame(A = 1:3, B = 2:4) %.% mutate(C = A + B) %.% select(C)
R environment crashed immediately.

I wonder if there will be an improvement to enhance select() to substitute mutate(), or at least providing a warning message for this case rather than crash.

@romainfrancois
Copy link
Member

Maybe this can be handled on the R side.

> data <- data.frame(A = 1:3, B = 2:4)
> select_vars( names(data), C = A+B )
 C
NA

I can at least make select_impl handle NA by throwing an error.

@hadley
Copy link
Member

hadley commented Mar 26, 2014

Duplicate of #302

@hadley hadley closed this as completed Mar 26, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants