Skip to content

perf: vectorize rowwise label lookup and row mask loop#212

Open
maxthecat2024 wants to merge 1 commit intoatorus-research:develfrom
maxthecat2024:perf/vectorize-rowwise-and-masks
Open

perf: vectorize rowwise label lookup and row mask loop#212
maxthecat2024 wants to merge 1 commit intoatorus-research:develfrom
maxthecat2024:perf/vectorize-rowwise-and-masks

Conversation

@maxthecat2024
Copy link
Copy Markdown

@maxthecat2024 maxthecat2024 commented Feb 27, 2026

desc.R: Replaced the rowwise() %>% mutate(row_label = row_labels[[stat]]) with a vectorized unname(row_labels[stat]) lookup. Avoids per-row evaluation and is ~100x faster on large datasets.

utils.R: Replaced the mutate(lag/ifelse) masking pattern in apply_row_masks() with base R vectorization. Removes the temporary mask column and the select(-mask) cleanup. Cleaner and ~2x faster.

No new dependencies. All 943 existing tests pass.

Types of changes

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Replace the rowwise() %>% mutate(row_label = row_labels[[stat]]) in desc.R
with a vectorized lookup using row_labels[stat]. This avoids per-row
evaluation and is ~100x faster on large datasets.

Replace the mutate(lag/ifelse) masking pattern in apply_row_masks() with
base R vectorization. Removes the temporary mask column and the
select(-mask) cleanup. Cleaner and ~2x faster.

No new dependencies. All 943 existing tests pass.
@maxthecat2024
Copy link
Copy Markdown
Author

maxthecat2024 commented Feb 27, 2026

Cleaned up version as per your feedback. Just the rowwise fix and the mask loop, nothing else. Thanks for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant