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

adply .id ignored + unwanted columns #295

Open
ghost opened this issue May 14, 2019 · 0 comments
Open

adply .id ignored + unwanted columns #295

ghost opened this issue May 14, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented May 14, 2019

I am unsure if this should be two separate bug reports, if this is a single issue with a common source, or if I am simply using it wrong.

library(plyr)
ir <- iris[1:2,]
adply(ir,1,function (x) data.frame(a=1),.id='row')

The expectation is that this snippet will run my function on each of the two rows in the ir data frame, rbind the results, and add an id column containing the margin index. Thus, the output I was expecting based on the documentation was:

  a row
1 1   1
2 1   2

However, the output obtained is:

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species a
1          5.1         3.5          1.4         0.2  setosa 1
2          4.9         3.0          1.4         0.2  setosa 1

Thus, (1) the .id argument seems to be ignored, and (2) adply seems to silently prepend the original columns to the output data frame, which I do not want. Both of these points seem to go against the documentation?

R 3.6.0, plyr 1.8.4, running on 64-bit Windows 10.

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

0 participants