Description Usage Arguments Details Value Author(s) Examples
Generate safe sequences by strictly enforcing either a positive or negative increment
1 2 3 |
from |
the starting and (maximal) end values of the
sequence. Of length |
to |
the starting and (maximal) end values of the
sequence. Of length |
by |
number: increment of the sequence. |
Creating sequences using either base::seq()
function or Colon
operator have a notable draw back of incorrectly generating positional
indices when a vector is empty. For example, consider x = NULL
. Then,
the expression 1:length(x)
would evaluate to 1:0
which expands to c(1,0)
.
As a result, any Control
may inadvertantly trigger an out of bounds
error on the initial run.
The safe_seq()
and %:%
operator seeks to prevent this issue by enforcing
either an ascending or descending sequence depending on the by
condition.
For the %:%
operator, note that this is restricted to being always
positive.
An integer vector that is either empty or contains a sequence of numbers.
JJB
1 2 3 4 5 6 7 8 9 10 11 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.