R - cpv (trotter package) and %dopar%
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'd like to know whether the cpv function within the trotter package works with %dopar%? I'm getting the following error:
task 1 failed - "object of type 'S4' is not subsettable"
Here's a small example:
library(doParallel)
library(trotter)
registerDoParallel(cores = 2)
x <- letters
combos <- cpv(2, 1:4)
print(combos)
num_combos <- length(combos)
results_list <- foreach(combo_num=1:num_combos) %dopar% { # many iterations
y <- x[combos[combo_num]]
# time consuming stuff follows that involves using y
}
Replacing %dopar% with %do% (or simply using a for loop) and it works fine.
r foreach doparallel
add a comment |
I'd like to know whether the cpv function within the trotter package works with %dopar%? I'm getting the following error:
task 1 failed - "object of type 'S4' is not subsettable"
Here's a small example:
library(doParallel)
library(trotter)
registerDoParallel(cores = 2)
x <- letters
combos <- cpv(2, 1:4)
print(combos)
num_combos <- length(combos)
results_list <- foreach(combo_num=1:num_combos) %dopar% { # many iterations
y <- x[combos[combo_num]]
# time consuming stuff follows that involves using y
}
Replacing %dopar% with %do% (or simply using a for loop) and it works fine.
r foreach doparallel
Hi, from the author of trotter (who has been very lazy in maintaining the R version of this library!). I copied-and-pasted your code and it worked as expected. Might your error come from something else you have done? Try restarting the R session...
– Richard Ambler
Nov 17 '18 at 4:55
I think the difference is that the OP is using windows, and you're not.
– F. Privé
Nov 17 '18 at 7:35
The problem here is that apparently you can't use subsetting on this kind of object without loading the package first. Maybe @RichardAmbler could fixed this, or maybe it's impossible depending on the kind of object system that's used.
– F. Privé
Nov 17 '18 at 7:42
@F.Privé Updating the R package has been added to my list of things to do! :) There shouldn't be an issue with subsetting, though, because the combinations are not actually stored anywhere; rather the cpv instance is just a mapping of integers to combinations that behaves as if it were a list of combinations. As long as the interpreter has a constructed cpv instance it should be able to access any combination "stored" without needing to explicitly partition the combinations for each core.
– Richard Ambler
Nov 17 '18 at 8:04
add a comment |
I'd like to know whether the cpv function within the trotter package works with %dopar%? I'm getting the following error:
task 1 failed - "object of type 'S4' is not subsettable"
Here's a small example:
library(doParallel)
library(trotter)
registerDoParallel(cores = 2)
x <- letters
combos <- cpv(2, 1:4)
print(combos)
num_combos <- length(combos)
results_list <- foreach(combo_num=1:num_combos) %dopar% { # many iterations
y <- x[combos[combo_num]]
# time consuming stuff follows that involves using y
}
Replacing %dopar% with %do% (or simply using a for loop) and it works fine.
r foreach doparallel
I'd like to know whether the cpv function within the trotter package works with %dopar%? I'm getting the following error:
task 1 failed - "object of type 'S4' is not subsettable"
Here's a small example:
library(doParallel)
library(trotter)
registerDoParallel(cores = 2)
x <- letters
combos <- cpv(2, 1:4)
print(combos)
num_combos <- length(combos)
results_list <- foreach(combo_num=1:num_combos) %dopar% { # many iterations
y <- x[combos[combo_num]]
# time consuming stuff follows that involves using y
}
Replacing %dopar% with %do% (or simply using a for loop) and it works fine.
r foreach doparallel
r foreach doparallel
edited Nov 17 '18 at 6:39
kit
1,10431017
1,10431017
asked Nov 17 '18 at 2:45
user10665650user10665650
82
82
Hi, from the author of trotter (who has been very lazy in maintaining the R version of this library!). I copied-and-pasted your code and it worked as expected. Might your error come from something else you have done? Try restarting the R session...
– Richard Ambler
Nov 17 '18 at 4:55
I think the difference is that the OP is using windows, and you're not.
– F. Privé
Nov 17 '18 at 7:35
The problem here is that apparently you can't use subsetting on this kind of object without loading the package first. Maybe @RichardAmbler could fixed this, or maybe it's impossible depending on the kind of object system that's used.
– F. Privé
Nov 17 '18 at 7:42
@F.Privé Updating the R package has been added to my list of things to do! :) There shouldn't be an issue with subsetting, though, because the combinations are not actually stored anywhere; rather the cpv instance is just a mapping of integers to combinations that behaves as if it were a list of combinations. As long as the interpreter has a constructed cpv instance it should be able to access any combination "stored" without needing to explicitly partition the combinations for each core.
– Richard Ambler
Nov 17 '18 at 8:04
add a comment |
Hi, from the author of trotter (who has been very lazy in maintaining the R version of this library!). I copied-and-pasted your code and it worked as expected. Might your error come from something else you have done? Try restarting the R session...
– Richard Ambler
Nov 17 '18 at 4:55
I think the difference is that the OP is using windows, and you're not.
– F. Privé
Nov 17 '18 at 7:35
The problem here is that apparently you can't use subsetting on this kind of object without loading the package first. Maybe @RichardAmbler could fixed this, or maybe it's impossible depending on the kind of object system that's used.
– F. Privé
Nov 17 '18 at 7:42
@F.Privé Updating the R package has been added to my list of things to do! :) There shouldn't be an issue with subsetting, though, because the combinations are not actually stored anywhere; rather the cpv instance is just a mapping of integers to combinations that behaves as if it were a list of combinations. As long as the interpreter has a constructed cpv instance it should be able to access any combination "stored" without needing to explicitly partition the combinations for each core.
– Richard Ambler
Nov 17 '18 at 8:04
Hi, from the author of trotter (who has been very lazy in maintaining the R version of this library!). I copied-and-pasted your code and it worked as expected. Might your error come from something else you have done? Try restarting the R session...
– Richard Ambler
Nov 17 '18 at 4:55
Hi, from the author of trotter (who has been very lazy in maintaining the R version of this library!). I copied-and-pasted your code and it worked as expected. Might your error come from something else you have done? Try restarting the R session...
– Richard Ambler
Nov 17 '18 at 4:55
I think the difference is that the OP is using windows, and you're not.
– F. Privé
Nov 17 '18 at 7:35
I think the difference is that the OP is using windows, and you're not.
– F. Privé
Nov 17 '18 at 7:35
The problem here is that apparently you can't use subsetting on this kind of object without loading the package first. Maybe @RichardAmbler could fixed this, or maybe it's impossible depending on the kind of object system that's used.
– F. Privé
Nov 17 '18 at 7:42
The problem here is that apparently you can't use subsetting on this kind of object without loading the package first. Maybe @RichardAmbler could fixed this, or maybe it's impossible depending on the kind of object system that's used.
– F. Privé
Nov 17 '18 at 7:42
@F.Privé Updating the R package has been added to my list of things to do! :) There shouldn't be an issue with subsetting, though, because the combinations are not actually stored anywhere; rather the cpv instance is just a mapping of integers to combinations that behaves as if it were a list of combinations. As long as the interpreter has a constructed cpv instance it should be able to access any combination "stored" without needing to explicitly partition the combinations for each core.
– Richard Ambler
Nov 17 '18 at 8:04
@F.Privé Updating the R package has been added to my list of things to do! :) There shouldn't be an issue with subsetting, though, because the combinations are not actually stored anywhere; rather the cpv instance is just a mapping of integers to combinations that behaves as if it were a list of combinations. As long as the interpreter has a constructed cpv instance it should be able to access any combination "stored" without needing to explicitly partition the combinations for each core.
– Richard Ambler
Nov 17 '18 at 8:04
add a comment |
1 Answer
1
active
oldest
votes
Depending on the cluster type one needs to explicitly specify the used packages via the .packages argument. The following should work:
library(doParallel)
library(trotter)
cl <- makePSOCKcluster(2)
registerDoParallel(cl=cl)
x <- letters
combos <- cpv(2, 1:4)
num_combos <- length(combos)
rl <- foreach(combo_num=1:num_combos, .packages="trotter") %dopar% {
x[combos[combo_num]]
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347736%2fr-cpv-trotter-package-and-dopar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Depending on the cluster type one needs to explicitly specify the used packages via the .packages argument. The following should work:
library(doParallel)
library(trotter)
cl <- makePSOCKcluster(2)
registerDoParallel(cl=cl)
x <- letters
combos <- cpv(2, 1:4)
num_combos <- length(combos)
rl <- foreach(combo_num=1:num_combos, .packages="trotter") %dopar% {
x[combos[combo_num]]
}
add a comment |
Depending on the cluster type one needs to explicitly specify the used packages via the .packages argument. The following should work:
library(doParallel)
library(trotter)
cl <- makePSOCKcluster(2)
registerDoParallel(cl=cl)
x <- letters
combos <- cpv(2, 1:4)
num_combos <- length(combos)
rl <- foreach(combo_num=1:num_combos, .packages="trotter") %dopar% {
x[combos[combo_num]]
}
add a comment |
Depending on the cluster type one needs to explicitly specify the used packages via the .packages argument. The following should work:
library(doParallel)
library(trotter)
cl <- makePSOCKcluster(2)
registerDoParallel(cl=cl)
x <- letters
combos <- cpv(2, 1:4)
num_combos <- length(combos)
rl <- foreach(combo_num=1:num_combos, .packages="trotter") %dopar% {
x[combos[combo_num]]
}
Depending on the cluster type one needs to explicitly specify the used packages via the .packages argument. The following should work:
library(doParallel)
library(trotter)
cl <- makePSOCKcluster(2)
registerDoParallel(cl=cl)
x <- letters
combos <- cpv(2, 1:4)
num_combos <- length(combos)
rl <- foreach(combo_num=1:num_combos, .packages="trotter") %dopar% {
x[combos[combo_num]]
}
answered Nov 17 '18 at 4:52
FlorianFlorian
1,152818
1,152818
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347736%2fr-cpv-trotter-package-and-dopar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hi, from the author of trotter (who has been very lazy in maintaining the R version of this library!). I copied-and-pasted your code and it worked as expected. Might your error come from something else you have done? Try restarting the R session...
– Richard Ambler
Nov 17 '18 at 4:55
I think the difference is that the OP is using windows, and you're not.
– F. Privé
Nov 17 '18 at 7:35
The problem here is that apparently you can't use subsetting on this kind of object without loading the package first. Maybe @RichardAmbler could fixed this, or maybe it's impossible depending on the kind of object system that's used.
– F. Privé
Nov 17 '18 at 7:42
@F.Privé Updating the R package has been added to my list of things to do! :) There shouldn't be an issue with subsetting, though, because the combinations are not actually stored anywhere; rather the cpv instance is just a mapping of integers to combinations that behaves as if it were a list of combinations. As long as the interpreter has a constructed cpv instance it should be able to access any combination "stored" without needing to explicitly partition the combinations for each core.
– Richard Ambler
Nov 17 '18 at 8:04