Learn R Programming

scCustomize (version 3.0.1)

seq_zeros: Create sequence with zeros

Description

Create sequences of numbers like seq() or seq_len() but with zeros prefixed to keep numerical order

Usage

seq_zeros(seq_length, num_zeros = NULL)

Value

vector of numbers in sequence

Arguments

seq_length

a seqeunce or numbers of numbers to create sequence. Users can provide sequence (1:XX) or number of values to add in sequence (will be used as second number in seq_len; 1:XX).

num_zeros

number of zeros to prefix sequence, default is (e.g, 01, 02, 03, ...)

References

Base code from stackoverflow post: https://stackoverflow.com/a/38825614

Examples

Run this code
# Using sequence
new_seq <- seq_zeros(seq_length = 1:15, num_zeros = 1)
new_seq

# Using number
new_seq <- seq_zeros(seq_length = 15, num_zeros = 1)
new_seq

# Sequence with 2 zeros
new_seq <- seq_zeros(seq_length = 1:15, num_zeros = 2)
new_seq

Run the code above in your browser using DataLab