We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Because the default combine function is different between foreach and pforeach, the default behaviors differ between foreach and pforeach.
> result1 <- foreach(i = 1:3) %do% { + list(df=iris[1:3, ], summary=summary(iris)) + } > class(result1[[1]]) [1] "list" > library(pforeach) > result2 <- pforeach(i = 1:3)({ + list(df=iris[1:3, ], summary=summary(iris)) + }) > class(result2[[1]]) [1] "data.frame"
To solve this issue, we have to write like the following right now in pforeach package.
> defcombine <- function(a, ...) c(a, list(...)) > result3 <- pforeach(i = 1:3, .combine=defcombine, .init=list())({ + list(df=iris[1:3, ], summary=summary(iris)) + }) > class(result3[[1]]) [1] "list"
Do you have any idea to deal with this more easily?
You can check the "defcombine" function used in foreach package in the following link:
The text was updated successfully, but these errors were encountered:
Set .c=list to use the default combine function of foreach.
.c=list
foreach
library(foreach) result1 <- foreach(i = 1:3) %do% { list(df=iris[1:3, ], summary=summary(iris)) } library(pforeach) result2 <- pforeach(i = 1:3, .c=list)({ list(df=iris[1:3, ], summary=summary(iris)) }) identical(result1, result2)
[1] TRUE
Sorry, something went wrong.
Thanks! That's easy enough!
No branches or pull requests
Because the default combine function is different between foreach and pforeach, the default behaviors differ between foreach and pforeach.
To solve this issue, we have to write like the following right now in pforeach package.
Do you have any idea to deal with this more easily?
You can check the "defcombine" function used in foreach package in the following link:
The text was updated successfully, but these errors were encountered: