Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

rxply can have one replication too many #198

Closed
pitakakariki opened this Issue Feb 13, 2014 · 2 comments

Comments

Projects
None yet
2 participants

I noticed this when I was using the iterators package with plyr. The rxply functions evaluate .expr one time too many because of the if.function(.expr) line:

library(plyr)
library(iterators)

i <- iter(1:10)
replicate(10, nextElem(i))
# [1]  1  2  3  4  5  6  7  8  9 10

i <- iter(1:10)
raply(10, nextElem(i))
# Error: StopIteration

i <- iter(1:10)
raply(9, nextElem(i))
# [1]  2  3  4  5  6  7  8  9 10

But even without another package, you can get weird behaviour:

r_ply(3, print("boo!"))
# [1] "boo!"
# [1] "boo!"
# [1] "boo!"
# [1] "boo!"
# NULL
Contributor

krlmlr commented Feb 15, 2014

Duplicate of #158? Should be fixed in the development version (according to #189), could you please install using

devtools::install_github("plyr", "hadley")

and re-test?

Sorry, yes this is no longer a problem in the dev version.

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