bcgov / bcgov/epi.branch.sim

Speed up combining dataframes

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
11
Forks
1
PR merge metrics
No merged PRs in 30d

Description

In [these lines](https://github.com/bcgov/epi.branch.sim/blob/69c2fd9f422cdcea6caa06d29facc74a921ba5ca/R/step_simulation.R#L158) 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.

Contributor guide

Open the contributing guide

Research direction

Start in R/step_simulation.R at the step_simulation() code around the linked rbind call. Trace how state_df rows are added and removed across the package, then identify the affected benchmarks or simulation checks. Done means reducing the repeated combining cost while preserving the existing simulation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.