chen.wq
chen.wq

Reputation: 41

how to make R parallel::parSapply run in absolute order of X?

parSapply(cl = NULL, X, FUN, ..., simplify = TRUE,
          USE.NAMES = TRUE)

By default it will run in random order of X. But I would like it scheduled in order of X. is that possible?

Upvotes: 1

Views: 76

Answers (1)

niths4u
niths4u

Reputation: 440

Scheduling in order of X is not directly possible. But there are multiple ways to get around this. One of the very easy way is to use foreach with the option

.inorder=TRUE

Giving a base example. Please change it based on your need

t <- foreach(x=X,.inorder=TRUE) %dopar % { FUN }

Upvotes: 1

Related Questions