bcgov / epi.branch.sim

Stochastic epidemiological branching simulation
Apache License 2.0
9 stars 1 forks source link

Speed up combining dataframes #3

Open henry-ngo opened 4 years ago

henry-ngo commented 4 years ago

In these lines of step_simulation() we use rbind to combine the data frame of existing cases with the data frame for new cases. This happens at least once in almost every time step and is potentially a major bottleneck in terms of speed.

Pre-allocating a large data frame, matrix or list would speed things up, however, that would require some adjustments throughout the package as the state_df data frame has rows removed as well as added. This requires a bit more effort and will be a goal for the next major release.