Skip to content

Fix vignette: replace inefficient do.call/lapply/file.info pattern#509

Merged
jeroen merged 2 commits intomainfrom
copilot/fix-vignette-infidelity
Mar 23, 2026
Merged

Fix vignette: replace inefficient do.call/lapply/file.info pattern#509
jeroen merged 2 commits intomainfrom
copilot/fix-vignette-infidelity

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 23, 2026

The function-comparisons vignette used a flawed base R equivalent for dir_info() — it omitted full.names = TRUE, causing file.info to fail unless the working directory happened to be "path", and unnecessarily used do.call(rbind, lapply(...)) despite file.info being vectorized.

Change

  • vignettes/function-comparisons.Rmd: Replace the base R equivalent for dir_info("path"):
# Before (broken without correct working directory, unnecessarily verbose)
do.call(rbind, lapply(list.files("path"), file.info))

# After (correct and concise)
file.info(list.files("path", full.names = TRUE))
Original prompt

This section details on the original issue you should resolve

<issue_title>vignette infelicity</issue_title>
<issue_description>The vignette includes this

do.call(rbind, lapply(list.files("path"), file.info))

However, this assumes the current working directory is path; moreover, base::file.info is already vectorized, so instead I'd recommend:

file.info(list.files("path", full.names = TRUE))

Thank you for considering.</issue_description>

<agent_instructions>Can you implement the sugggestion</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…apply pattern

Co-authored-by: jeroen <216319+jeroen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/r-lib/fs/sessions/46edf87e-5ca3-4e25-b3e1-2ac4d1167515
Copilot AI changed the title [WIP] Fix vignette infelicity in file handling Fix vignette: replace inefficient do.call/lapply/file.info pattern Mar 23, 2026
Copilot AI requested a review from jeroen March 23, 2026 10:47
@jeroen jeroen marked this pull request as ready for review March 23, 2026 10:58
@jeroen jeroen merged commit 26c9c4c into main Mar 23, 2026
@jeroen jeroen deleted the copilot/fix-vignette-infidelity branch March 23, 2026 10:59
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.

vignette infelicity

2 participants