mcapply to get list of dataframes

Here, I am trying to join two dataframes that are from different lists. I would like to get it using either mcmapply or mclapply i.e. parallel way.

Here is the code:

set.seed(1000)
a=data.frame(sl=seq(5),temp1=sample(5))
b=data.frame(sl=seq(7),temp1=sample(7))

c=data.frame(sl=seq(5),temp2=sample(5))
d=data.frame(sl=seq(7),temp2=sample(7))


f1 <-list(a,b)
f2 <-list(c,d)

library(dplyr)

func=function(x,y){
  z1=x
  z2=y
  dat=left_join(z1,z2, by="sl")
  return(dat)
  }

This code below comes with an output of different output.

parallel::mcmapply(function(x,y){
  return(func(x,y))
}, x = f1, y = f2, mc.cores=1)
parallel::mcmapply(function(x,y){
  return(func(x,y))
}, x = f1, y = f2, mc.cores=1,
SIMPLIFY = FALSE)

?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.