I am trying to run a simulation in parallel.
iterations = 50000
sim = foreach(i=1:iterations) %dopar% sim(dataframe, ... )
Each item in the list sim is a dataframe with 40 columns and 100 rows. Each dataframe has an ID column. I want to determine the average score by ID over 50,000 simulations.
I tried the following, but it was quite slow, I think because it had to constantly regrow the dataframe:
results = do.call(rbind.data.frame, sim)
avg.scores = ddply(sim,~Player,summarise,mean=mean(score))
I also tried to set the attributes on the list to convert it to a dataframe in place (Most efficient list to data.frame method?), but ended up with way more than 25 columns and different column names
I am not sure whether there is a way to calculate the averages by iterating over the lists or whether I need to create a dataframe or datatable first, and then calculate the averages.
Thank you for any suggestions!