-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Using for(i in 1:n), especially for(i in 1:length(x)), is in general unsafe in R because if n=0, then 1:0 is not an empty vector (it actually has 2 elements: 1 and 0). So, one either needs to always check that n > 0 just before the for loop or use for(i in seq_len(n)) instead.
https://win-vector.com/2018/02/19/r-tip-use-seq_len-to-avoid-the-backwards-sequence-bug/
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels