Skip to content

adply .id ignored + unwanted columns #295

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions