Skip to content

docs: fix shift.Rd Value section to reflect vector return for single n#7780

Closed
LeonidasZhak wants to merge 1 commit into
Rdatatable:masterfrom
LeonidasZhak:docs/fix-shift-value-section
Closed

docs: fix shift.Rd Value section to reflect vector return for single n#7780
LeonidasZhak wants to merge 1 commit into
Rdatatable:masterfrom
LeonidasZhak:docs/fix-shift-value-section

Conversation

@LeonidasZhak
Copy link
Copy Markdown

Changes

Fixed the Value section of shift.Rd to accurately describe the return type behavior.

Problem

The Value section stated:

A list containing the lead/lag of input x.

But shift() returns a vector (not a list) when x is atomic and length(n) == 1. This is confirmed by src/shift.c:181:

if (isVectorAtomic(obj) && length(ans) == 1) ans = VECTOR_ELT(ans, 0);

The Details section already documented this behavior correctly, but the Value section was inaccurate.

Fix

Updated the Value section to:

When x is a vector and length(n) == 1, a vector of the same type and length as x. Otherwise, a list of vectors (one element for each combination of input column and n value).

Stata migration relevance

This fix is particularly important for Stata migrants who expect consistent return types from lag/lead operations. Stata's L.var always returns a vector, and the inaccurate Value section could lead users to believe shift() always returns a list, causing unexpected behavior in their code.

Validation

  • tools::checkRd('man/shift.Rd') passes (no errors)
  • Change is purely documentation (no code changes)
  • No other open PRs address this specific issue

Duplicate check

The Value section previously stated 'A list containing the lead/lag of
input x', but shift() returns a vector (not a list) when x is atomic
and length(n) == 1. This is confirmed by src/shift.c:181:
  if (isVectorAtomic(obj) && length(ans) == 1) ans = VECTOR_ELT(ans, 0);

The inaccurate Value section could confuse Stata migrants expecting
consistent return types from lag/lead operations.
@LeonidasZhak
Copy link
Copy Markdown
Author

I am withdrawing this PR as part of a broader cleanup of an oversized automated contribution batch. I am sorry for the review noise and the pressure this may have put on maintainers. Going forward I will keep contributions to this project much more limited and higher-signal, ideally only one or two focused PRs at a time. Thank you for maintaining the project.

@ben-schwen
Copy link
Copy Markdown
Member

@LeonidasZhak please read our contribution guidelines regarding the use of AI

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