Skip to content

Fix select_rows_and_columns() silently returning a vector for single row/column selections - #77

Merged
vertesy merged 1 commit into
devfrom
fix/select-rows-cols-drop
Sep 1, 2026
Merged

vertesy merged 1 commit into
devfrom
fix/select-rows-cols-drop

Conversation

@vertesy

@vertesy vertesy commented Sep 1, 2026

Copy link
Copy Markdown
Owner

The bug

Both subset operations, df[true_rownames, ] and df[, true_colnames], were missing drop = FALSE. Base R's default drop = TRUE collapses a data.frame subset to a plain vector whenever exactly one row or one column is selected, silently changing the return type from data.frame to vector for any caller who requests a single RowID or ColID. This also broke the function's own trailing Stringendo::iprint(dim(df)) diagnostic, which prints NULL for a vector instead of the actual dimensions.

Fix

Add drop = FALSE to both subset operations, matching the same fix already applied to other functions in this file (combine.matrices.by.rowname.intersect, merge_numeric_df_by_rn).

Verification


Generated by Claude Code

…row/column selections

Both subset operations, df[true_rownames, ] and df[, true_colnames],
were missing drop = FALSE. Base R's default drop = TRUE collapses a
data.frame subset to a plain vector whenever exactly one row or one
column is selected, silently changing the return type from
data.frame to vector for any caller who requests a single RowID or
ColID. This also broke the function's own trailing
Stringendo::iprint(dim(df)) diagnostic, which prints NULL for a
vector instead of the actual dimensions.

Fix: add drop = FALSE to both subset operations, matching the same
fix already applied to other functions in this file
(combine.matrices.by.rowname.intersect, merge_numeric_df_by_rn).

Verified: selecting a single column (ColIDs = "a") and a single row
(RowIDs = "r1") now both correctly return a data.frame with the
expected dim() printed, instead of silently degrading to a vector;
the normal multi-row/multi-col case is unaffected.

Version bumped 2.8.16 -> 2.8.19 (distinct from sibling PRs #75/#76,
which also branch from the same 2.8.16 base and already claimed
2.8.17/2.8.18).
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.

2 participants