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

Select should be able to rename variables #192

Closed
hadley opened this issue Jan 20, 2014 · 6 comments
Closed

Select should be able to rename variables #192

hadley opened this issue Jan 20, 2014 · 6 comments
Milestone

Comments

@hadley
Copy link
Member

@hadley hadley commented Jan 20, 2014

But what should select(sepal = c(Sepal.Width, Sepal.Length)) do?

  • an error?
  • add sepal as a prefix to existing names?
  • create new names with sepal as prefix? (sepal1, sepal2)
@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Jan 22, 2014

Maybe we can replace c by something else, which would control what to do. e.g.

select(sepal = prefix(Sepal.Width, Sepal.Length))

@hadley
Copy link
Member Author

@hadley hadley commented Jan 22, 2014

I think that's possible, but maybe challenging due to how evaluation currently works for select.

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Jan 22, 2014

Sure. Perhaps I was anticipating this: #172
I was just wondering if conceptually syntax like this would be interesting. Too bad we can't have functions in the rhs:

select( prefix(sepal) = c(Sepal.Width, Sepal.Length))

Could use := but then it looks like data.table refugee.

select( prefix(sepal) := c(Sepal.Width, Sepal.Length))

@hadley
Copy link
Member Author

@hadley hadley commented Jan 22, 2014

Well, you can define "prefix<-" <- function(x, value) {}...

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Jan 22, 2014

It does not make select( prefix(sepal) = c(Sepal.Width, Sepal.Length)) parsable.

> "prefix<-" <- function(x, value) {}
> parse( text = 'select( prefix(sepal) = c(Sepal.Width, Sepal.Length))' )
Erreur dans parse(text = "select( prefix(sepal) = c(Sepal.Width, Sepal.Length))") :
  <text>:1:23: '=' inattendu(e)
1: select( prefix(sepal) =

@hadley
Copy link
Member Author

@hadley hadley commented Jan 22, 2014

Oh bummer, I thought it would.

hadley added a commit that referenced this issue Feb 4, 2014
@hadley hadley closed this in d948c6e Feb 4, 2014
@hadley hadley added this to the v0.1.2 milestone Feb 17, 2014
@hadley hadley removed this from the v0.2 milestone Feb 17, 2014
krlmlr pushed a commit to krlmlr/dplyr that referenced this issue Mar 2, 2016
@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants