pad0(1:5, 7) # Pad to length 7 with zeroes
pad0(1:5, 3) # no padding, but cut at length 3
# 3 leading zeroes, then the vector start (10 elements of vector, no additional padding needed):
pad0(1:10, 13, start = 3)
# padding with value other than zero:
pad0(1:5, 7, value = "pad")
Run the code above in your browser using DataLab