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

Special variables 'i' and 'n' in d_ply functions used with summarise/mutate #272

Open
tzoltak opened this issue Mar 9, 2016 · 2 comments

Comments

@tzoltak
Copy link

tzoltak commented Mar 9, 2016

It seems that when summarise() or mutate() is used along with d.ply functions there are two special variables: 'n' and 'i' that describe overall number of groups and consecutive number of group. These variables mask global variables of the same names which someone pottentialy may want to use in formulas to construct new variables with summarise() or mutate(). I know that's rather unusual (perhaps even quirky) case and I don't advocate for change of this behavior. However it would be good idea to mention about it in documentation of summarise() and mutate().

@crowding
Copy link
Contributor

?here
Try ddply(df, here(mutate), ...). Or dplyr :)

On Wed, Mar 9, 2016 at 1:05 AM, tzoltak notifications@github.com wrote:

It seems that when summarise() or mutate() is used along with d.ply
functions there are two special variables: 'n' and 'i' that describe
overall number of groups and consecutive number of group. These variables
mask global variables of the same names which someone pottentialy may want
to use in formulas to construct new variables with summarise() or mutate().
I know that's rather unusual (perhaps even quirky) case and I don't
advocate for change of this behavior. However it would be good idea to
mention about it in documentation of summarise() and mutate().


Reply to this email directly or view it on GitHub
#272.

@tzoltak
Copy link
Author

tzoltak commented Mar 11, 2016

Thanks, but you missed my point. When you know that d.ply() with summarise()/mutate() do such a thing, there are many simple ways to make your code working as you wish. The problem is, that it is rather hard to find out, what causes your code working wrong when this behavior isn't documented.

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