Skip to content

Conversation

@aakritixyz
Copy link

This PR includes minor documentation improvements to base R functions:
1. paste.Rd
• Clarified why paste0() is slightly more efficient than paste().
• Explained recycle0 behavior when collapse is specified.
2. substr.Rd
• Added a note about zero-length extraction: when start or stop results in zero-length, an empty string "" is returned.
• Updated examples to demonstrate zero-length behavior.

These changes improve clarity for users reading the documentation, without modifying any code behavior.

@JesseAlderliesten
Copy link

The bullet-point list mentions 'Explained recycle0 behavior when collapse is specified.' for paste.Rd but as far as I can tell, you did not change the explanation about recycle0?

@JesseAlderliesten
Copy link

The examples added to substr.Rd are useful, but the comment '## Demonstrating zero-length extraction behavior' is misleading: 'character(0)' in the first example indeed is zero-length, but '""' in the second example has length 1, even though it contains zero characters: length("") == 1 but nchar("") == 0.
Maybe rephrase it as '## Extraction behavior from zero-length strings and empty strings'?

@aakritixyz
Copy link
Author

Hi Sir

Thanks for your feedback! I apologize for not including the changes you suggested in my previous commit , I realized after pushing that I had only partially staged the updates, so the examples and comments weren’t fully updated.

I’ve now incorporated your suggestions:
• In substr.Rd, the comment has been clarified to distinguish zero-length vectors (character(0)) from empty strings ("").
• In paste.Rd, examples now demonstrate recycle0 behavior when collapse is specified.

Both changes are included in the latest commit. PTAL , thanks!

@JesseAlderliesten
Copy link

No problem! However, I would not add the examples in paste.Rd, since there are already examples showing the use of 'collapse' and 'recycle0' (below the headings ## 'recycle0 = TRUE' and '## When 'collapse = ').
If you want to keep the examples, your first example should probably use paste0(...) instead of paste(...) because paste(...) returns " a, b".

@aakritixyz
Copy link
Author

Thanks for the clarification!
I’ve removed the additional examples from paste.Rd to avoid redundancy, since the use of collapse and recycle0 is already well covered under the existing sections.

No new examples are added now, and the documentation remains unchanged functionally. Please let me know if this looks good or if you’d prefer a different approach.

@JesseAlderliesten
Copy link

Looks good to me, but you'll have to wait for a response of one of the R maintainers. I'm just a fellow-coder who saw your remark in the R-contributers Slack.

@aakritixyz
Copy link
Author

Thanks for taking a look and for the helpful guidance!
I’ll wait for feedback from one of the R maintainers. Much appreciated.

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