Skip to content

Dev - #32

Merged
vertesy merged 8 commits into
mainfrom
dev
Sep 1, 2026
Merged

Dev#32
vertesy merged 8 commits into
mainfrom
dev

Conversation

@vertesy

@vertesy vertesy commented Sep 1, 2026

Copy link
Copy Markdown
Owner

No description provided.

vertesy and others added 7 commits August 6, 2025 11:52
…-documentation

Polish function documentation
* Annotate code; flag 3 pre-existing bugs (not fixed)

* Fix 3 bugs flagged in PR #30 review

- read.simple.ssv(): add missing `asTibble` parameter (was referenced
  but never defined, erroring whenever wRownames = TRUE, the default).
- write.simple.xlsx(): assignRownames() now uses its own argument `x`
  instead of the undefined `df`, fixing has_row_names = FALSE.
- qs.2.table(): fix `qs:qread` -> `qs::qread`, use the real
  `stringi::stri_detect_regex` function, and define `base_filename`/
  `out_path` on every branch so the function actually runs. Also adds
  `stringi` to Imports/NAMESPACE since it's now genuinely used.

Co-authored-by: Abel Vertesy <5101911+vertesy@users.noreply.github.com>

* Fix qs.2.table()'s excel branch crashing on a bare data.frame

write.simple.xlsx() requires a list of sheets; qs.2.table() was
passing the loaded table directly, which fails its
is.data.frame(x)-per-element assertion. Wrap it in a list first.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Abel Vertesy <5101911+vertesy@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
# Conflicts:
#	DESCRIPTION
#	R/ReadWriter.R
#	R/list.of.functions.in.ReadWriter.md
#	README.md
#	man/column.2.row.names.Rd
#	man/read.simple.csv.named.vector.Rd
#	man/read.simple.ssv.Rd

Co-authored-by: vertesy <5101911+vertesy@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e43ad13b4b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread NAMESPACE
importFrom(readr,read_csv2)
importFrom(readr,read_delim)
importFrom(readr,read_tsv)
importFrom(stringi,stri_detect_regex)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Declare stringi in DESCRIPTION

Adding this namespace import makes stringi a direct package dependency, but DESCRIPTION still omits it from Imports. Consequently, clean installations do not guarantee that stringi is installed and R CMD check can reject the undeclared namespace dependency; add stringi to DESCRIPTION as required for new dependencies.

AGENTS.md reference: AGENTS.md:L13-L19

Useful? React with 👍 / 👎.

Comment thread R/ReadWriter.R
Comment on lines +961 to 962
assignRownames <- function(x) column.2.row.names(x, rowname_column = rowname_column, make_names = TRUE)
named_list <- lapply(named_list, assignRownames)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve converted row names in the workbook

When has_row_names = FALSE, this now-working branch calls column.2.row.names(), which removes the selected identifier column and stores it as row names. The subsequent openxlsx::write.xlsx(..., rowNames = has_row_names) still passes FALSE, so those row names are also omitted and every identifier in the selected column is silently lost from the workbook; the converted row names need to be enabled for writing on this path.

Useful? React with 👍 / 👎.

@vertesy

vertesy commented Sep 1, 2026

Copy link
Copy Markdown
Owner Author

@claude

could you please address the Codex code review suggestions in this PR?

1
"Preserve converted row names in the workbook

When has_row_names = FALSE, this now-working branch calls column.2.row.names(), which removes the selected identifier column and stores it as row names. The subsequent openxlsx::write.xlsx(..., rowNames = has_row_names) still passes FALSE, so those row names are also omitted and every identifier in the selected column is silently lost from the workbook; the converted row names need to be enabled for writing on this path."

I have to say, I I'm not fully confident about this suggestion because these functions have been working very robustly and reliably for years. I'm not sure if simply Codex is misunderstanding something about the operation of these functions, so please be careful when reviewing this comment. Consider the context and the intended output. If you decide to change, then please make it explicitly clear with simple English and examples what and how the output will change.


2
"Declare stringi in DESCRIPTION

Adding this namespace import makes stringi a direct package dependency, but DESCRIPTION still omits it from Imports. Consequently, clean installations do not guarantee that stringi is installed and R CMD check can reject the undeclared namespace dependency; add stringi to DESCRIPTION as required for new dependencies."

@claude

claude Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Claude finished @vertesy's task in 3m 16s —— View job


Addressed both Codex review suggestions

  • Gather context (read files, CLAUDE.md, PR diff)
  • Investigate row-names issue in write.simple.xlsx (R/ReadWriter.R:962)
  • Fix stringi missing from DESCRIPTION Imports
  • Decide on row-names fix carefully (verify against intended behavior)
  • Commit & push
  • Summarize

1. stringi dependency — fixed, straightforward

R/ReadWriter.R (line ~1150, in read.simple.qs or similar) calls stringi::stri_detect_regex(...), and NAMESPACE already has importFrom(stringi, stri_detect_regex). But DESCRIPTION never listed stringi under Imports, so a clean install wouldn't guarantee it's present and R CMD check would flag it. Added stringi to Imports: in DESCRIPTION.

2. Row names lost in write.simple.xlsx() when has_row_names = FALSE — this one is a real bug, but a very narrow, easy-to-miss one. Here's why it wasn't caught for years, and exactly what changes:

Why you never noticed it: Before this PR, that code branch read column.2.row.names(df, ...) — using a variable df that doesn't exist anywhere in the function. Every time someone actually called write.simple.xlsx(..., has_row_names = FALSE), it would have thrown Error: object 'df' not found. This PR's own fix (changing df → x) is what makes the branch run at all for the first time. So the "robust for years" experience comes from has_row_names = TRUE (the default) — the FALSE path was effectively dead code until this PR revived it.

What the code does today (with just the df→x fix, before my change):

  1. You pass a list of data frames with an identifier column (e.g. "gene") and has_row_names = FALSE.
  2. column.2.row.names() removes the "gene" column and stores those values as the data frame's row names.
  3. The final openxlsx::write.xlsx(..., rowNames = has_row_names) still passes the original has_row_names, which is FALSE — so write.xlsx is told "don't write row names."
  4. Net result: the "gene" column is gone from the data (moved to row names in step 2), and then row names aren't written either. The identifiers vanish from the Excel file entirely — not moved to be the first column, just lost.

Example:

df <- data.frame(gene = c("TP53", "MYC"), value = c(1, 2))
write.simple.xlsx(df, has_row_names = FALSE)
# Before my fix: the .xlsx has only one column "value" (1, 2) — "TP53"/"MYC" are gone.
# After my fix:  the .xlsx has row names "TP53"/"MYC" in the leftmost (unlabeled)
#                 column, and "value" next to them — matching what has_row_names = FALSE
#                 is documented to do ("converts the first column to row names").

The fix (R/ReadWriter.R): introduced a separate write_row_names flag that starts equal to has_row_names, but gets set to TRUE right after the conversion happens. has_row_names itself (the input parameter) is untouched, so behavior when it's TRUE (the default, and the path used "for years") is completely unchanged. Only the previously-broken FALSE path now actually preserves the identifiers instead of silently dropping them.

If, after seeing this example, you determine the identifiers were intentionally meant to be dropped in some existing workflow (rather than preserved as row names), let me know and I'll revert just that part — but based on the parameter's own documentation ("converts the first column to row names"), preserving them seems to be the intended behavior.

Note: No R installation was available in this environment, so I could not run R CMD check, devtools::document(), or execute the reproducible example above — please verify locally before merging. git diff confirms only the intended lines changed.

Pushed as commit b74b0d5 to dev.

…on xlsx export

- DESCRIPTION: add stringi to Imports, since R/ReadWriter.R now calls
  stringi::stri_detect_regex() and NAMESPACE already declares the importFrom.
- write.simple.xlsx(): when has_row_names = FALSE, the identifier column is
  moved into row names via column.2.row.names() before writing. The final
  write.xlsx() call still passed the original has_row_names (FALSE) as
  rowNames, so those converted identifiers were dropped from the workbook.
  Track the post-conversion state separately (write_row_names) and pass that
  to write.xlsx() instead.

Co-authored-by: Abel Vertesy <5101911+vertesy@users.noreply.github.com>
@vertesy
vertesy merged commit 3aef631 into main Sep 1, 2026
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