I have a function that needs to manipulate three data frames, all with different structure:
a
: Original data frame. It is a parameter for my function. I need to remove rows from here, given certain conditions.b
: New data frame created in my function. My function adds all the rows here.c
: Another new data frame created in my function. My function adds all the rows here.
In order to try the parallel processing, I sat up a minimal code (following this question and this blog) in which I only generated b
:
# Set up the parallel
registerDoParallel( makeCluster(3L) )
b <- foreach(i = 1:nrow(f), .combine = rbind) %dopar% {
tempB <- do_something_function()
tempB
}
That example works perfectly, but I'm missing two data frames. I found other answers, but I do believe my case is different:
- Saving multiple outputs of foreach dopar loop -> As far as I understand, this is working with lists and not with data frames. Plus, all the results are "new" data frames, when I need to successively subset an existing data frame.
- Output list of two rbinded data frames with foreach in R -> This one says that all data frames must have the same structure. Mine do not.
I could change a
to be a data frame of rows that would later be removed, but I need to merge all tempA
with only tempA
... if that makes any sense. In the previous questions I linked, they mix all of the outputs.