Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use seq_along() instead of 1:length() #236

Merged
merged 1 commit into from
Nov 23, 2020

Conversation

shrektan
Copy link
Contributor

I think seq_along() is better than 1:length() as the latter will cause unexpected results when x is length zero. In addition, it's faster.

x <- character()
1:length(x)
#> [1] 1 0
seq_along(x)
#> integer(0)

Created on 2020-11-23 by the reprex package (v0.3.0)

@JohnCoene
Copy link
Owner

Indeed, I always overlook this.

@JohnCoene JohnCoene merged commit 9f22f61 into JohnCoene:master Nov 23, 2020
@shrektan shrektan deleted the seq_along branch November 23, 2020 16:12
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.

None yet

2 participants