Skip to content

Subset data frames with dplyr, not base [] - #112

Merged
d-morrison merged 3 commits into
mainfrom
claude/project-thread-69unta
Nov 10, 2026
Merged

d-morrison merged 3 commits into
mainfrom
claude/project-thread-69unta

Conversation

@d-morrison

Copy link
Copy Markdown
Contributor

Requested by Ezra · project thread

Closes #111.

Ezra, 2026-11-10: "psc: let's use dplyr's filter() and select() to subset datasets in R, instead of base [] (for example https://morrison-lab.github.io/lds/chapters/discriminant-analysis.html#sol-lab-knn-split)"

  • chapters/coding-style/tidyverse-replacements.qmd: new "Subsetting data frames" section.
  • lms::base_subset_linter(): flags a [ call with an empty index (df[i, ], df[, j]); added to default_linters(nested_calls = TRUE); matrices take # nolint. Its tests pass locally (11 pass, 0 fail; the 2 warnings are the cyclocomp package missing here).
  • Callers' lms-ref moves to the merged commit in a later step; the check is diff-scoped, so no sweep.

Generated by Claude Code

Ezra, 2026-11-10: "psc: let's use dplyr's filter() and select() to subset
datasets in R, instead of base []".

Adds the rule to the tidyverse-replacements page and a base_subset_linter()
to lms, in default_linters(nested_calls = TRUE), that flags df[i, ] and
df[, j]. Matrices take # nolint.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9ngiGnksZTebJnriQk
undesirable_function_linter flags a local named message.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9ngiGnksZTebJnriQk
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

…subset rule

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9ngiGnksZTebJnriQk
@github-actions

Copy link
Copy Markdown
Contributor

Claude finished review — View run


This matches the computed range exactly — no surprise files. The .Rd edit is a faithful mirror of the roxygen change (same word reordering, same wrapping), consistent with what devtools::document() would regenerate, so it wasn't hand-edited incorrectly.

Both of the two blocking findings from the prior review round (commit e6cf808) have been correctly and completely fixed in this round (commit d2b665a), with no new regressions introduced. I have no new findings.

Review: PR #112 — "Subset data frames with dplyr, not base []"

What changed since the last review round

Only the two fixes requested in the prior review were made, exactly as described:

  • chapters/coding-style/tidyverse-replacements.qmd:33 — heading changed from ## Subsetting data frames to ### Subsetting data frames. Verified it now nests correctly under ## Tidyverse Replacements {#sec-tidyverse-replacements} in chapters/coding-style.qmd:87, matching the ### convention used by every other included fragment in chapters/coding-style/.
  • lms/R/default_linters.R:12-14 — the @param nested_calls roxygen text now reads "...ggplot_args_linter(), aes_args_named_linter() and base_subset_linter()," correctly placing "and" before the new last item.
  • lms/man/default_linters.Rd:10-13 — the generated doc was correctly regenerated to match the fixed roxygen comment (not hand-patched out of sync).

No other files changed in this range (git diff --stat e6cf808a d2b665a6 shows only these three files, 5 insertions/5 deletions), so nothing else needs re-review. All items verified as correct in the prior round's "Things verified as correct" section still stand since the underlying linter logic, tests, and example content are untouched in this range.

Verdict

Ready for merge — both previously required fixes are correctly and completely applied, with no new issues introduced.

Structured Review Data (JSON)
{
  "schema_version": "1.1",
  "reviewer": "claude",
  "commit_sha": "d2b665a6efbdaba1209c760df4ba38d673edd1b8",
  "verdict": "CLEAN",
  "findings": [],
  "detailed_assessment": "The heading in tidyverse-replacements.qmd now uses ### and nests correctly under Tidyverse Replacements, and default_linters.R plus its generated Rd correctly reorder the and conjunction before base_subset_linter.",
  "holistic_assessment": "Both fixes match the prior review requirements exactly, the Rd file stays in sync with roxygen source, and no unrelated files or regressions were introduced in this round's diff."
}

Reviewed commit: db644f9

@github-actions

Copy link
Copy Markdown
Contributor

💰 Cost: $0.2349 (review) — run

@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2
🚀 Preview available at: https://Morrison-Lab.github.io/psc/pr-preview/pr-112/

Built to branch gh-pages at 2026-11-10 18:47 UTC.

@d-morrison
d-morrison merged commit 5831ead into main Nov 10, 2026
19 checks passed
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.

Use dplyr filter() and select() to subset datasets in R, not base []

2 participants