safe_seq_len | R Documentation |
Modified version of base::seq_len()
that returns a zero-length integer in case of a zero-length input instead of throwing an error.
safe_seq_len(n)
n |
Desired length of the integer sequence. |
An integer sequence starting from 1L
.
Other statistical computing / numeric functions:
round_to()
,
safe_max()
,
safe_min()
,
stat_mode()
pal::safe_seq_len(5)
# this function simply returns a zero-length integer for zero-length inputs...
pal::safe_seq_len(NULL)
pal::safe_seq_len(integer())
# ...while `seq_len()` throws an error
try(seq_len(NULL))
try(seq_len(integer()))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.